@sajn/embed-react 0.1.1 → 0.1.3
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/README.md +30 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +8 -9
- package/dist/sign-document.d.ts +2 -2
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @sajn/embed-react
|
|
2
|
+
|
|
3
|
+
React component for embedding sajn's e-signature functionality directly into your applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sajn/embed-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { EmbedSignDocument } from '@sajn/embed-react';
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<EmbedSignDocument
|
|
19
|
+
documentId="your-document-id"
|
|
20
|
+
token="your-token"
|
|
21
|
+
onSignerCompleted={(data) => console.log('Signed!', data)}
|
|
22
|
+
onSignerRejected={(data) => console.log('Rejected', data)}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
For full documentation, events, and configuration options, see the [main README](https://github.com/sajn-se/embeds#readme).
|
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
|
|
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
|
|
2
|
-
import { useRef as
|
|
3
|
-
function
|
|
4
|
-
const a =
|
|
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
|
-
|
|
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 =
|
|
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__ */
|
|
40
|
+
}), [t]), /* @__PURE__ */ r("iframe", { ref: a, className: e.className, src: c() });
|
|
42
41
|
}
|
|
43
42
|
export {
|
|
44
|
-
|
|
43
|
+
g as EmbedSignDocument
|
|
45
44
|
};
|
package/dist/sign-document.d.ts
CHANGED
|
@@ -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;
|