@documenso/embed-preact 0.1.0 → 0.2.0-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,58 @@
1
+ export type CssVars = {
2
+ /** Base background color */
3
+ background?: string | null;
4
+ /** Base text color */
5
+ foreground?: string | null;
6
+ /** Muted/subtle background color */
7
+ muted?: string | null;
8
+ /** Muted/subtle text color */
9
+ mutedForeground?: string | null;
10
+ /** Popover/dropdown background color */
11
+ popover?: string | null;
12
+ /** Popover/dropdown text color */
13
+ popoverForeground?: string | null;
14
+ /** Card background color */
15
+ card?: string | null;
16
+ /** Card border color */
17
+ cardBorder?: string | null;
18
+ /** Card border tint/highlight color */
19
+ cardBorderTint?: string | null;
20
+ /** Card text color */
21
+ cardForeground?: string | null;
22
+ /** Field card background color */
23
+ fieldCard?: string | null;
24
+ /** Field card border color */
25
+ fieldCardBorder?: string | null;
26
+ /** Field card text color */
27
+ fieldCardForeground?: string | null;
28
+ /** Widget background color */
29
+ widget?: string | null;
30
+ /** Widget text color */
31
+ widgetForeground?: string | null;
32
+ /** Default border color */
33
+ border?: string | null;
34
+ /** Input field border color */
35
+ input?: string | null;
36
+ /** Primary action/button color */
37
+ primary?: string | null;
38
+ /** Primary action/button text color */
39
+ primaryForeground?: string | null;
40
+ /** Secondary action/button color */
41
+ secondary?: string | null;
42
+ /** Secondary action/button text color */
43
+ secondaryForeground?: string | null;
44
+ /** Accent/highlight color */
45
+ accent?: string | null;
46
+ /** Accent/highlight text color */
47
+ accentForeground?: string | null;
48
+ /** Destructive/danger action color */
49
+ destructive?: string | null;
50
+ /** Destructive/danger text color */
51
+ destructiveForeground?: string | null;
52
+ /** Focus ring color */
53
+ ring?: string | null;
54
+ /** Border radius size in REM units */
55
+ radius?: string | null;
56
+ /** Warning/alert color */
57
+ warning?: string | null;
58
+ };
@@ -1,11 +1,13 @@
1
1
  import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
2
3
  export type EmbedDirectTemplateProps = {
3
4
  className?: string;
4
5
  host?: string;
5
6
  token: string;
6
7
  externalId?: string;
7
8
  css?: string | undefined;
8
- cssVars?: Record<string, string> | undefined;
9
+ cssVars?: (CssVars & Record<string, string>) | undefined;
10
+ darkModeDisabled?: boolean | undefined;
9
11
  email?: string | undefined;
10
12
  lockEmail?: boolean | undefined;
11
13
  name?: string | undefined;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("preact"),u=require("preact/hooks");var _=0;function f(e,t,o,m,n,c){t||(t={});var a,d,i=t;if("ref"in i)for(d in i={},t)d=="ref"?a=t[d]:i[d]=t[d];var l={type:e,props:i,key:o,ref:a,__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 t=u.useRef(null);function o(){const n=e.host||"https://app.documenso.com",c=btoa(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css})),a=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&a.searchParams.set("externalId",e.externalId),`${a}#${c}`}function m(n){var c,a,d,i,l,s;if(((c=t.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.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 u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:t,className:e.className,src:o()})}function k(e){const t=u.useRef(null);function o(){const n=e.host||"https://app.documenso.com",c=btoa(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css}));return`${new URL(`/embed/sign/${e.token}`,n)}#${c}`}function m(n){var c,a,d,i;if(((c=t.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.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 u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:t,className:e.className,src:o()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;
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;
package/dist/index.mjs CHANGED
@@ -1,33 +1,37 @@
1
- import { options as f } from "preact";
2
- import { useRef as s, useEffect as o } from "preact/hooks";
1
+ import { options as r } from "preact";
2
+ import { useRef as f, useEffect as u } from "preact/hooks";
3
3
  var k = 0;
4
- function _(e, a, u, m, n, c) {
4
+ function _(e, a, o, m, n, t) {
5
5
  a || (a = {});
6
- var t, d, i = a;
7
- if ("ref" in i) for (d in i = {}, a) d == "ref" ? t = a[d] : i[d] = a[d];
8
- 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: --k, __i: -1, __u: 0, __source: n, __self: c };
9
- return f.vnode && f.vnode(l), l;
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;
10
10
  }
11
11
  function w(e) {
12
- const a = s(null);
13
- function u() {
14
- const n = e.host || "https://app.documenso.com", c = btoa(
15
- JSON.stringify({
16
- name: e.name,
17
- lockName: e.lockName,
18
- email: e.email,
19
- lockEmail: e.lockEmail,
20
- css: e.css
21
- })
22
- ), t = new URL(`/embed/direct/${e.token}`, n);
23
- return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${c}`;
12
+ const a = f(null);
13
+ function o() {
14
+ const n = e.host || "https://app.documenso.com", t = btoa(
15
+ encodeURIComponent(
16
+ JSON.stringify({
17
+ name: e.name,
18
+ lockName: e.lockName,
19
+ email: e.email,
20
+ lockEmail: e.lockEmail,
21
+ css: e.css,
22
+ cssVars: e.cssVars,
23
+ darkModeDisabled: e.darkModeDisabled
24
+ })
25
+ )
26
+ ), c = new URL(`/embed/direct/${e.token}`, n);
27
+ return e.externalId && c.searchParams.set("externalId", e.externalId), `${c}#${t}`;
24
28
  }
25
29
  function m(n) {
26
- var c, t, d, i, l, r;
27
- if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
30
+ var t, c, d, i, l, s;
31
+ if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
28
32
  switch (n.data.action) {
29
33
  case "document-ready":
30
- (t = e.onDocumentReady) == null || t.call(e);
34
+ (c = e.onDocumentReady) == null || c.call(e);
31
35
  break;
32
36
  case "document-completed":
33
37
  (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
@@ -39,34 +43,38 @@ function w(e) {
39
43
  (l = e.onFieldSigned) == null || l.call(e);
40
44
  break;
41
45
  case "field-unsigned":
42
- (r = e.onFieldUnsigned) == null || r.call(e);
46
+ (s = e.onFieldUnsigned) == null || s.call(e);
43
47
  break;
44
48
  }
45
49
  }
46
- return o(() => {
50
+ return u(() => {
47
51
  window.addEventListener("message", m);
48
- }, []), o(() => () => {
52
+ }, []), u(() => () => {
49
53
  window.removeEventListener("message", m);
50
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
54
+ }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
51
55
  }
52
- function E(e) {
53
- const a = s(null);
54
- function u() {
55
- const n = e.host || "https://app.documenso.com", c = btoa(
56
- JSON.stringify({
57
- name: e.name,
58
- lockName: e.lockName,
59
- css: e.css
60
- })
56
+ function D(e) {
57
+ const a = f(null);
58
+ function o() {
59
+ const n = e.host || "https://app.documenso.com", t = btoa(
60
+ encodeURIComponent(
61
+ JSON.stringify({
62
+ name: e.name,
63
+ lockName: e.lockName,
64
+ css: e.css,
65
+ cssVars: e.cssVars,
66
+ darkModeDisabled: e.darkModeDisabled
67
+ })
68
+ )
61
69
  );
62
- return `${new URL(`/embed/sign/${e.token}`, n)}#${c}`;
70
+ return `${new URL(`/embed/sign/${e.token}`, n)}#${t}`;
63
71
  }
64
72
  function m(n) {
65
- var c, t, d, i;
66
- if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
73
+ var t, c, d, i;
74
+ if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
67
75
  switch (n.data.action) {
68
76
  case "document-ready":
69
- (t = e.onDocumentReady) == null || t.call(e);
77
+ (c = e.onDocumentReady) == null || c.call(e);
70
78
  break;
71
79
  case "document-completed":
72
80
  (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
@@ -76,13 +84,13 @@ function E(e) {
76
84
  break;
77
85
  }
78
86
  }
79
- return o(() => {
87
+ return u(() => {
80
88
  window.addEventListener("message", m);
81
- }, []), o(() => () => {
89
+ }, []), u(() => () => {
82
90
  window.removeEventListener("message", m);
83
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
91
+ }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
84
92
  }
85
93
  export {
86
94
  w as EmbedDirectTemplate,
87
- E as EmbedSignDocument
95
+ D as EmbedSignDocument
88
96
  };
@@ -1,10 +1,12 @@
1
1
  import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
2
3
  export type EmbedSignDocumentProps = {
3
4
  className?: string;
4
5
  host?: string;
5
6
  token: string;
6
7
  css?: string | undefined;
7
- cssVars?: Record<string, string> | undefined;
8
+ cssVars?: (CssVars & Record<string, string>) | undefined;
9
+ darkModeDisabled?: boolean | undefined;
8
10
  name?: string | undefined;
9
11
  lockName?: boolean | undefined;
10
12
  onDocumentReady?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-preact",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-rc.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"