@sajn/embed-react 0.1.5 → 0.1.6

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.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react");function d(e){const t=c.useRef(null);function o(){const n=e.host||"https://app.sajn.se",s=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)}#${s}`}const a=c.useCallback(n=>{if(t.current?.contentWindow===n.source)switch(n.data.action){case"document-ready":t.current?.contentWindow?.postMessage({action:"embed-init"},new URL(e.host||"https://app.sajn.se").origin),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.host,e.onDocumentReady,e.onSignerCompleted,e.onDocumentError,e.onSignerRejected]);return c.useEffect(()=>(window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}),[a]),r.jsx("iframe",{ref:t,className:e.className,src:o()})}function u(e){const t=c.useRef(null);function o(){const n=e.host||"https://app.sajn.se",s=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)}#${s}`}const a=c.useCallback(n=>{if(t.current?.contentWindow===n.source)switch(n.data.action){case"document-ready":t.current?.contentWindow?.postMessage({action:"embed-init"},new URL(e.host||"https://app.sajn.se").origin),e.onDocumentReady?.();break;case"document-error":e.onDocumentError?.(n.data.data);break}},[e.host,e.onDocumentReady,e.onDocumentError]);return c.useEffect(()=>(window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}),[a]),r.jsx("iframe",{ref:t,className:e.className,src:o()})}exports.EmbedSignDocument=d;exports.EmbedViewDocument=u;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { useRef as s, useCallback as d, useEffect as i } from "react";
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useRef as r, useCallback as d, useEffect as i } from "react";
3
3
  function g(e) {
4
- const a = s(null);
4
+ const t = r(null);
5
5
  function o() {
6
6
  const n = e.host || "https://app.sajn.se", c = btoa(
7
7
  encodeURIComponent(
@@ -16,12 +16,15 @@ function g(e) {
16
16
  );
17
17
  return `${new URL(`/embed/sign/${e.documentId}?token=${e.token}`, n)}#${c}`;
18
18
  }
19
- const t = d(
19
+ const a = d(
20
20
  (n) => {
21
- if (a.current?.contentWindow === n.source)
21
+ if (t.current?.contentWindow === n.source)
22
22
  switch (n.data.action) {
23
23
  case "document-ready":
24
- e.onDocumentReady?.();
24
+ t.current?.contentWindow?.postMessage(
25
+ { action: "embed-init" },
26
+ new URL(e.host || "https://app.sajn.se").origin
27
+ ), e.onDocumentReady?.();
25
28
  break;
26
29
  case "signer-completed":
27
30
  e.onSignerCompleted?.(n.data.data);
@@ -34,14 +37,14 @@ function g(e) {
34
37
  break;
35
38
  }
36
39
  },
37
- [e.onDocumentReady, e.onSignerCompleted, e.onDocumentError, e.onSignerRejected]
40
+ [e.host, e.onDocumentReady, e.onSignerCompleted, e.onDocumentError, e.onSignerRejected]
38
41
  );
39
- return i(() => (window.addEventListener("message", t), () => {
40
- window.removeEventListener("message", t);
41
- }), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
42
+ return i(() => (window.addEventListener("message", a), () => {
43
+ window.removeEventListener("message", a);
44
+ }), [a]), /* @__PURE__ */ s("iframe", { ref: t, className: e.className, src: o() });
42
45
  }
43
46
  function w(e) {
44
- const a = s(null);
47
+ const t = r(null);
45
48
  function o() {
46
49
  const n = e.host || "https://app.sajn.se", c = btoa(
47
50
  encodeURIComponent(
@@ -55,23 +58,26 @@ function w(e) {
55
58
  );
56
59
  return `${new URL(`/embed/view/${e.documentId}?token=${e.token}`, n)}#${c}`;
57
60
  }
58
- const t = d(
61
+ const a = d(
59
62
  (n) => {
60
- if (a.current?.contentWindow === n.source)
63
+ if (t.current?.contentWindow === n.source)
61
64
  switch (n.data.action) {
62
65
  case "document-ready":
63
- e.onDocumentReady?.();
66
+ t.current?.contentWindow?.postMessage(
67
+ { action: "embed-init" },
68
+ new URL(e.host || "https://app.sajn.se").origin
69
+ ), e.onDocumentReady?.();
64
70
  break;
65
71
  case "document-error":
66
72
  e.onDocumentError?.(n.data.data);
67
73
  break;
68
74
  }
69
75
  },
70
- [e.onDocumentReady, e.onDocumentError]
76
+ [e.host, e.onDocumentReady, e.onDocumentError]
71
77
  );
72
- return i(() => (window.addEventListener("message", t), () => {
73
- window.removeEventListener("message", t);
74
- }), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
78
+ return i(() => (window.addEventListener("message", a), () => {
79
+ window.removeEventListener("message", a);
80
+ }), [a]), /* @__PURE__ */ s("iframe", { ref: t, className: e.className, src: o() });
75
81
  }
76
82
  export {
77
83
  g as EmbedSignDocument,
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
1
  {
2
- "name": "@sajn/embed-react",
3
- "version": "0.1.5",
4
- "description": "React component for embedding sajn e-signature functionality",
5
- "homepage": "https://github.com/sajn-se/embeds#readme",
6
- "bugs": {
7
- "url": "https://github.com/sajn-se/embeds/issues"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/sajn-se/embeds.git"
12
- },
13
- "license": "MIT",
14
- "author": "sajn",
15
- "type": "commonjs",
16
- "exports": {
17
- "./package.json": "./package.json",
18
- ".": {
19
- "import": {
20
- "types": "./dist/index.d.mts",
21
- "default": "./dist/index.mjs"
22
- },
23
- "require": {
24
- "types": "./dist/index.d.ts",
25
- "default": "./dist/index.js"
26
- }
27
- }
28
- },
29
- "main": "dist/index.js",
30
- "types": "dist/index.d.ts",
31
- "files": [
32
- "dist"
33
- ],
34
- "scripts": {
35
- "build": "vite build",
36
- "clean": "rimraf node_modules && rimraf dist",
37
- "check-exports": "attw --pack .",
38
- "publint": "publint"
39
- },
40
- "devDependencies": {
41
- "@types/react": "^18.0.0 || ^19.0.0",
42
- "@vitejs/plugin-react": "^5.0.0",
43
- "vite": "^7.0.0",
44
- "vite-plugin-dts": "^4.1.0"
45
- },
46
- "peerDependencies": {
47
- "react": "^18.0.0 || ^19.0.0",
48
- "react-dom": "^18.0.0 || ^19.0.0"
49
- },
50
- "publishConfig": {
51
- "access": "public"
52
- },
53
- "module": "dist/index.mjs"
54
- }
2
+ "name": "@sajn/embed-react",
3
+ "version": "0.1.6",
4
+ "description": "React component for embedding sajn e-signature functionality",
5
+ "homepage": "https://github.com/sajn-se/embeds#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/sajn-se/embeds/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/sajn-se/embeds.git"
12
+ },
13
+ "license": "MIT",
14
+ "author": "sajn",
15
+ "type": "commonjs",
16
+ "exports": {
17
+ "./package.json": "./package.json",
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.mts",
21
+ "default": "./dist/index.mjs"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ }
28
+ },
29
+ "main": "dist/index.js",
30
+ "types": "dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "devDependencies": {
35
+ "@types/react": "^18.0.0 || ^19.0.0",
36
+ "@vitejs/plugin-react": "^5.0.0",
37
+ "vite": "^7.0.0",
38
+ "vite-plugin-dts": "^4.1.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.0.0 || ^19.0.0",
42
+ "react-dom": "^18.0.0 || ^19.0.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "module": "dist/index.mjs",
48
+ "scripts": {
49
+ "build": "vite build",
50
+ "clean": "rimraf node_modules && rimraf dist",
51
+ "check-exports": "attw --pack .",
52
+ "publint": "publint"
53
+ }
54
+ }