@sajn/embed-react 0.1.5 → 0.1.7

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 CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as EmbedSignDocument } from './sign-document';
2
- export type { Language, EmbedSignDocumentProps } from './sign-document';
2
+ export type { Language, SignatureInputMode, EmbedSignDocumentProps } from './sign-document';
3
3
  export { default as EmbedViewDocument } from './view-document';
4
4
  export type { EmbedViewDocumentProps } from './view-document';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as EmbedSignDocument } from './sign-document';
2
- export type { Language, EmbedSignDocumentProps } from './sign-document';
2
+ export type { Language, SignatureInputMode, EmbedSignDocumentProps } from './sign-document';
3
3
  export { default as EmbedViewDocument } from './view-document';
4
4
  export type { EmbedViewDocumentProps } from './view-document';
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,signatureInputModes:e.signatureInputModes,...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(
@@ -10,18 +10,22 @@ function g(e) {
10
10
  cssVars: e.cssVars,
11
11
  allowDocumentRejection: e.allowDocumentRejection,
12
12
  showScrollIndicator: e.showScrollIndicator ?? !0,
13
+ signatureInputModes: e.signatureInputModes,
13
14
  ...e.additionalProps
14
15
  })
15
16
  )
16
17
  );
17
18
  return `${new URL(`/embed/sign/${e.documentId}?token=${e.token}`, n)}#${c}`;
18
19
  }
19
- const t = d(
20
+ const a = d(
20
21
  (n) => {
21
- if (a.current?.contentWindow === n.source)
22
+ if (t.current?.contentWindow === n.source)
22
23
  switch (n.data.action) {
23
24
  case "document-ready":
24
- e.onDocumentReady?.();
25
+ t.current?.contentWindow?.postMessage(
26
+ { action: "embed-init" },
27
+ new URL(e.host || "https://app.sajn.se").origin
28
+ ), e.onDocumentReady?.();
25
29
  break;
26
30
  case "signer-completed":
27
31
  e.onSignerCompleted?.(n.data.data);
@@ -34,14 +38,14 @@ function g(e) {
34
38
  break;
35
39
  }
36
40
  },
37
- [e.onDocumentReady, e.onSignerCompleted, e.onDocumentError, e.onSignerRejected]
41
+ [e.host, e.onDocumentReady, e.onSignerCompleted, e.onDocumentError, e.onSignerRejected]
38
42
  );
39
- return i(() => (window.addEventListener("message", t), () => {
40
- window.removeEventListener("message", t);
41
- }), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
43
+ return i(() => (window.addEventListener("message", a), () => {
44
+ window.removeEventListener("message", a);
45
+ }), [a]), /* @__PURE__ */ s("iframe", { ref: t, className: e.className, src: o() });
42
46
  }
43
47
  function w(e) {
44
- const a = s(null);
48
+ const t = r(null);
45
49
  function o() {
46
50
  const n = e.host || "https://app.sajn.se", c = btoa(
47
51
  encodeURIComponent(
@@ -55,23 +59,26 @@ function w(e) {
55
59
  );
56
60
  return `${new URL(`/embed/view/${e.documentId}?token=${e.token}`, n)}#${c}`;
57
61
  }
58
- const t = d(
62
+ const a = d(
59
63
  (n) => {
60
- if (a.current?.contentWindow === n.source)
64
+ if (t.current?.contentWindow === n.source)
61
65
  switch (n.data.action) {
62
66
  case "document-ready":
63
- e.onDocumentReady?.();
67
+ t.current?.contentWindow?.postMessage(
68
+ { action: "embed-init" },
69
+ new URL(e.host || "https://app.sajn.se").origin
70
+ ), e.onDocumentReady?.();
64
71
  break;
65
72
  case "document-error":
66
73
  e.onDocumentError?.(n.data.data);
67
74
  break;
68
75
  }
69
76
  },
70
- [e.onDocumentReady, e.onDocumentError]
77
+ [e.host, e.onDocumentReady, e.onDocumentError]
71
78
  );
72
- return i(() => (window.addEventListener("message", t), () => {
73
- window.removeEventListener("message", t);
74
- }), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: o() });
79
+ return i(() => (window.addEventListener("message", a), () => {
80
+ window.removeEventListener("message", a);
81
+ }), [a]), /* @__PURE__ */ s("iframe", { ref: t, className: e.className, src: o() });
75
82
  }
76
83
  export {
77
84
  g as EmbedSignDocument,
@@ -1,5 +1,6 @@
1
1
  import { CssVars } from './css-vars';
2
2
  export type Language = 'sv' | 'en' | 'no' | 'da' | 'fi' | 'de' | 'is' | 'es' | 'fr' | 'it';
3
+ export type SignatureInputMode = 'draw' | 'type' | 'upload';
3
4
  export type EmbedSignDocumentProps = {
4
5
  language?: Language;
5
6
  className?: string;
@@ -9,6 +10,8 @@ export type EmbedSignDocumentProps = {
9
10
  cssVars?: (CssVars & Record<string, string>) | undefined;
10
11
  allowDocumentRejection?: boolean | undefined;
11
12
  showScrollIndicator?: boolean | undefined;
13
+ /** Which signature input modes the pad offers (default: all). Only narrows the workspace allowlist. */
14
+ signatureInputModes?: SignatureInputMode[] | undefined;
12
15
  additionalProps?: Record<string, string | number | boolean> | undefined;
13
16
  onDocumentReady?: () => void;
14
17
  onSignerCompleted?: (data: {
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.7",
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
+ }