@documenso/embed-preact 0.1.0 → 0.2.0-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.
@@ -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"),u=require("preact/hooks");var _=0;function f(e,a,l,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 s={type:e,props:i,key:l,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(s),s}function b(e){const a=u.useRef(null);function l(){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,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,s,o;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":(s=e.onFieldSigned)==null||s.call(e);break;case"field-unsigned":(o=e.onFieldUnsigned)==null||o.call(e);break}}return u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:l()})}function k(e){const a=u.useRef(null);function l(){const n=e.host||"https://app.documenso.com",c=btoa(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 u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:l()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;
package/dist/index.mjs CHANGED
@@ -1,33 +1,35 @@
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 o } from "preact/hooks";
3
3
  var k = 0;
4
- function _(e, a, u, m, n, c) {
4
+ function _(e, a, l, 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 u = { type: e, props: i, key: l, 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(u), u;
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(
12
+ const a = f(null);
13
+ function l() {
14
+ const n = e.host || "https://app.documenso.com", t = btoa(
15
15
  JSON.stringify({
16
16
  name: e.name,
17
17
  lockName: e.lockName,
18
18
  email: e.email,
19
19
  lockEmail: e.lockEmail,
20
- css: e.css
20
+ css: e.css,
21
+ cssVars: e.cssVars,
22
+ darkModeDisabled: e.darkModeDisabled
21
23
  })
22
- ), t = new URL(`/embed/direct/${e.token}`, n);
23
- return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${c}`;
24
+ ), c = new URL(`/embed/direct/${e.token}`, n);
25
+ return e.externalId && c.searchParams.set("externalId", e.externalId), `${c}#${t}`;
24
26
  }
25
27
  function m(n) {
26
- var c, t, d, i, l, r;
27
- if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
28
+ var t, c, d, i, u, s;
29
+ if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
28
30
  switch (n.data.action) {
29
31
  case "document-ready":
30
- (t = e.onDocumentReady) == null || t.call(e);
32
+ (c = e.onDocumentReady) == null || c.call(e);
31
33
  break;
32
34
  case "document-completed":
33
35
  (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
@@ -36,10 +38,10 @@ function w(e) {
36
38
  (i = e.onDocumentError) == null || i.call(e, n.data.data);
37
39
  break;
38
40
  case "field-signed":
39
- (l = e.onFieldSigned) == null || l.call(e);
41
+ (u = e.onFieldSigned) == null || u.call(e);
40
42
  break;
41
43
  case "field-unsigned":
42
- (r = e.onFieldUnsigned) == null || r.call(e);
44
+ (s = e.onFieldUnsigned) == null || s.call(e);
43
45
  break;
44
46
  }
45
47
  }
@@ -47,26 +49,28 @@ function w(e) {
47
49
  window.addEventListener("message", m);
48
50
  }, []), o(() => () => {
49
51
  window.removeEventListener("message", m);
50
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
52
+ }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: l() });
51
53
  }
52
- function E(e) {
53
- const a = s(null);
54
- function u() {
55
- const n = e.host || "https://app.documenso.com", c = btoa(
54
+ function D(e) {
55
+ const a = f(null);
56
+ function l() {
57
+ const n = e.host || "https://app.documenso.com", t = btoa(
56
58
  JSON.stringify({
57
59
  name: e.name,
58
60
  lockName: e.lockName,
59
- css: e.css
61
+ css: e.css,
62
+ cssVars: e.cssVars,
63
+ darkModeDisabled: e.darkModeDisabled
60
64
  })
61
65
  );
62
- return `${new URL(`/embed/sign/${e.token}`, n)}#${c}`;
66
+ return `${new URL(`/embed/sign/${e.token}`, n)}#${t}`;
63
67
  }
64
68
  function m(n) {
65
- var c, t, d, i;
66
- if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
69
+ var t, c, d, i;
70
+ if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
67
71
  switch (n.data.action) {
68
72
  case "document-ready":
69
- (t = e.onDocumentReady) == null || t.call(e);
73
+ (c = e.onDocumentReady) == null || c.call(e);
70
74
  break;
71
75
  case "document-completed":
72
76
  (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
@@ -80,9 +84,9 @@ function E(e) {
80
84
  window.addEventListener("message", m);
81
85
  }, []), o(() => () => {
82
86
  window.removeEventListener("message", m);
83
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
87
+ }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: l() });
84
88
  }
85
89
  export {
86
90
  w as EmbedDirectTemplate,
87
- E as EmbedSignDocument
91
+ D as EmbedSignDocument
88
92
  };
@@ -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.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"