@sajn/embed-react 0.1.2 → 0.1.4

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 +1,2 @@
1
1
  export { default as EmbedSignDocument } from './sign-document';
2
+ export type { Language, EmbedSignDocumentProps } from './sign-document';
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { default as EmbedSignDocument } from './sign-document';
2
+ export type { Language, EmbedSignDocumentProps } from './sign-document';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react");function d(e){const c=a.useRef(null);function o(){const n=e.host||"https://app.sajn.se",s=btoa(encodeURIComponent(JSON.stringify({name:e.name,css:e.css,cssVars:e.cssVars,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.documentId}?token=${e.token}`,n)}#${s}`}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]),r.jsx("iframe",{ref:c,className:e.className,src:o()})}exports.EmbedSignDocument=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react");function d(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,...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()})}exports.EmbedSignDocument=d;
package/dist/index.mjs CHANGED
@@ -1,13 +1,12 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { useRef as r, useCallback as d, useEffect as i } from "react";
3
- function f(e) {
4
- const a = r(null);
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useRef as d, useCallback as s, useEffect as i } from "react";
3
+ function g(e) {
4
+ const a = d(null);
5
5
  function c() {
6
6
  const n = e.host || "https://app.sajn.se", o = btoa(
7
7
  encodeURIComponent(
8
8
  JSON.stringify({
9
- name: e.name,
10
- css: e.css,
9
+ language: e.language ?? "en",
11
10
  cssVars: e.cssVars,
12
11
  allowDocumentRejection: e.allowDocumentRejection,
13
12
  ...e.additionalProps
@@ -16,7 +15,7 @@ function f(e) {
16
15
  );
17
16
  return `${new URL(`/embed/sign/${e.documentId}?token=${e.token}`, n)}#${o}`;
18
17
  }
19
- const t = d(
18
+ const t = s(
20
19
  (n) => {
21
20
  if (a.current?.contentWindow === n.source)
22
21
  switch (n.data.action) {
@@ -38,8 +37,8 @@ function f(e) {
38
37
  );
39
38
  return i(() => (window.addEventListener("message", t), () => {
40
39
  window.removeEventListener("message", t);
41
- }), [t]), /* @__PURE__ */ s("iframe", { ref: a, className: e.className, src: c() });
40
+ }), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: c() });
42
41
  }
43
42
  export {
44
- f as EmbedSignDocument
43
+ g as EmbedSignDocument
45
44
  };
@@ -1,12 +1,12 @@
1
1
  import { CssVars } from './css-vars';
2
+ export type Language = 'sv' | 'en' | 'no' | 'da' | 'fi' | 'de' | 'is' | 'es' | 'fr' | 'it';
2
3
  export type EmbedSignDocumentProps = {
4
+ language?: Language;
3
5
  className?: string;
4
6
  host?: string;
5
7
  token: string;
6
8
  documentId: string;
7
- css?: string | undefined;
8
9
  cssVars?: (CssVars & Record<string, string>) | undefined;
9
- name?: string | undefined;
10
10
  allowDocumentRejection?: boolean | undefined;
11
11
  additionalProps?: Record<string, string | number | boolean> | undefined;
12
12
  onDocumentReady?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sajn/embed-react",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "React component for embedding sajn e-signature functionality",
5
5
  "homepage": "https://github.com/sajn-se/embeds#readme",
6
6
  "bugs": {