@sajn/embed-react 0.1.4 → 0.1.5
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +43 -8
- package/dist/sign-document.d.ts +5 -4
- package/dist/view-document.d.ts +19 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react");function i(e){const c=a.useRef(null);function o(){const n=e.host||"https://app.sajn.se",r=btoa(encodeURIComponent(JSON.stringify({language:e.language??"en",cssVars:e.cssVars,allowDocumentRejection:e.allowDocumentRejection,showScrollIndicator:e.showScrollIndicator??!0,...e.additionalProps})));return`${new URL(`/embed/sign/${e.documentId}?token=${e.token}`,n)}#${r}`}const t=a.useCallback(n=>{if(c.current?.contentWindow===n.source)switch(n.data.action){case"document-ready":e.onDocumentReady?.();break;case"signer-completed":e.onSignerCompleted?.(n.data.data);break;case"document-error":e.onDocumentError?.(n.data.data);break;case"signer-rejected":e.onSignerRejected?.(n.data.data);break}},[e.onDocumentReady,e.onSignerCompleted,e.onDocumentError,e.onSignerRejected]);return a.useEffect(()=>(window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}),[t]),s.jsx("iframe",{ref:c,className:e.className,src:o()})}function u(e){const c=a.useRef(null);function o(){const n=e.host||"https://app.sajn.se",r=btoa(encodeURIComponent(JSON.stringify({language:e.language??"en",cssVars:e.cssVars,showScrollIndicator:e.showScrollIndicator??!0,...e.additionalProps})));return`${new URL(`/embed/view/${e.documentId}?token=${e.token}`,n)}#${r}`}const t=a.useCallback(n=>{if(c.current?.contentWindow===n.source)switch(n.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-error":e.onDocumentError?.(n.data.data);break}},[e.onDocumentReady,e.onDocumentError]);return a.useEffect(()=>(window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}),[t]),s.jsx("iframe",{ref:c,className:e.className,src:o()})}exports.EmbedSignDocument=i;exports.EmbedViewDocument=u;
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as s, useCallback as d, useEffect as i } from "react";
|
|
3
3
|
function g(e) {
|
|
4
|
-
const a =
|
|
5
|
-
function
|
|
6
|
-
const n = e.host || "https://app.sajn.se",
|
|
4
|
+
const a = s(null);
|
|
5
|
+
function o() {
|
|
6
|
+
const n = e.host || "https://app.sajn.se", c = btoa(
|
|
7
7
|
encodeURIComponent(
|
|
8
8
|
JSON.stringify({
|
|
9
9
|
language: e.language ?? "en",
|
|
10
10
|
cssVars: e.cssVars,
|
|
11
11
|
allowDocumentRejection: e.allowDocumentRejection,
|
|
12
|
+
showScrollIndicator: e.showScrollIndicator ?? !0,
|
|
12
13
|
...e.additionalProps
|
|
13
14
|
})
|
|
14
15
|
)
|
|
15
16
|
);
|
|
16
|
-
return `${new URL(`/embed/sign/${e.documentId}?token=${e.token}`, n)}#${
|
|
17
|
+
return `${new URL(`/embed/sign/${e.documentId}?token=${e.token}`, n)}#${c}`;
|
|
17
18
|
}
|
|
18
|
-
const t =
|
|
19
|
+
const t = d(
|
|
19
20
|
(n) => {
|
|
20
21
|
if (a.current?.contentWindow === n.source)
|
|
21
22
|
switch (n.data.action) {
|
|
@@ -37,8 +38,42 @@ function g(e) {
|
|
|
37
38
|
);
|
|
38
39
|
return i(() => (window.addEventListener("message", t), () => {
|
|
39
40
|
window.removeEventListener("message", t);
|
|
40
|
-
}), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src:
|
|
41
|
+
}), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
|
|
42
|
+
}
|
|
43
|
+
function w(e) {
|
|
44
|
+
const a = s(null);
|
|
45
|
+
function o() {
|
|
46
|
+
const n = e.host || "https://app.sajn.se", c = btoa(
|
|
47
|
+
encodeURIComponent(
|
|
48
|
+
JSON.stringify({
|
|
49
|
+
language: e.language ?? "en",
|
|
50
|
+
cssVars: e.cssVars,
|
|
51
|
+
showScrollIndicator: e.showScrollIndicator ?? !0,
|
|
52
|
+
...e.additionalProps
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
return `${new URL(`/embed/view/${e.documentId}?token=${e.token}`, n)}#${c}`;
|
|
57
|
+
}
|
|
58
|
+
const t = d(
|
|
59
|
+
(n) => {
|
|
60
|
+
if (a.current?.contentWindow === n.source)
|
|
61
|
+
switch (n.data.action) {
|
|
62
|
+
case "document-ready":
|
|
63
|
+
e.onDocumentReady?.();
|
|
64
|
+
break;
|
|
65
|
+
case "document-error":
|
|
66
|
+
e.onDocumentError?.(n.data.data);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[e.onDocumentReady, e.onDocumentError]
|
|
71
|
+
);
|
|
72
|
+
return i(() => (window.addEventListener("message", t), () => {
|
|
73
|
+
window.removeEventListener("message", t);
|
|
74
|
+
}), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
|
|
41
75
|
}
|
|
42
76
|
export {
|
|
43
|
-
g as EmbedSignDocument
|
|
77
|
+
g as EmbedSignDocument,
|
|
78
|
+
w as EmbedViewDocument
|
|
44
79
|
};
|
package/dist/sign-document.d.ts
CHANGED
|
@@ -8,12 +8,13 @@ export type EmbedSignDocumentProps = {
|
|
|
8
8
|
documentId: string;
|
|
9
9
|
cssVars?: (CssVars & Record<string, string>) | undefined;
|
|
10
10
|
allowDocumentRejection?: boolean | undefined;
|
|
11
|
+
showScrollIndicator?: boolean | undefined;
|
|
11
12
|
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
12
13
|
onDocumentReady?: () => void;
|
|
13
14
|
onSignerCompleted?: (data: {
|
|
14
15
|
token: string;
|
|
15
|
-
documentId:
|
|
16
|
-
signerId:
|
|
16
|
+
documentId: string;
|
|
17
|
+
signerId: string;
|
|
17
18
|
failed?: string;
|
|
18
19
|
}) => void;
|
|
19
20
|
onDocumentError?: (data: {
|
|
@@ -22,8 +23,8 @@ export type EmbedSignDocumentProps = {
|
|
|
22
23
|
}) => void;
|
|
23
24
|
onSignerRejected?: (data: {
|
|
24
25
|
token: string;
|
|
25
|
-
documentId:
|
|
26
|
-
signerId:
|
|
26
|
+
documentId: string;
|
|
27
|
+
signerId: string;
|
|
27
28
|
reason: string;
|
|
28
29
|
}) => void;
|
|
29
30
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CssVars } from './css-vars';
|
|
2
|
+
export type Language = 'sv' | 'en' | 'no' | 'da' | 'fi' | 'de' | 'is' | 'es' | 'fr' | 'it';
|
|
3
|
+
export type EmbedViewDocumentProps = {
|
|
4
|
+
language?: Language;
|
|
5
|
+
className?: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
token: string;
|
|
8
|
+
documentId: string;
|
|
9
|
+
cssVars?: (CssVars & Record<string, string>) | undefined;
|
|
10
|
+
showScrollIndicator?: boolean | undefined;
|
|
11
|
+
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
12
|
+
onDocumentReady?: () => void;
|
|
13
|
+
onDocumentError?: (data: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
};
|
|
18
|
+
declare function EmbedViewDocument(props: EmbedViewDocumentProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default EmbedViewDocument;
|