@mxenabled/web-connect-widget-sdk 0.0.3 → 0.0.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/README.md +25 -0
- package/dist/ConnectWidget.d.ts +1 -1
- package/dist/index.js +2 -6
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# MX Web Connect Widget SDK
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
The purpose of this project is to be able to easily integrate the MX connect widget into a web app.
|
|
6
|
+
|
|
7
|
+
## Implementation guide
|
|
8
|
+
|
|
9
|
+
The implementation guide lives in the MX docs [here](Add something here when it exists).
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
This package mounts an connect widget iframe to the DOM, listens for post messages, and provides callbacks for handling MX events.
|
|
14
|
+
|
|
15
|
+
## API Documentation
|
|
16
|
+
|
|
17
|
+
The api documentation is [here](./API.md)
|
|
18
|
+
|
|
19
|
+
## Contributing
|
|
20
|
+
|
|
21
|
+
Read the [contributing guide](./CONTRIBUTING.md) to learn about the development process.
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
This project is lincensed under the terms of the [MIT license](LICENSE).
|
package/dist/ConnectWidget.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Event } from './consts';
|
|
|
2
2
|
interface ConnectWidgetProps {
|
|
3
3
|
containerSelector: string;
|
|
4
4
|
iframeProps?: Record<string, unknown>;
|
|
5
|
-
onEvent
|
|
5
|
+
onEvent: (event: Event) => void;
|
|
6
6
|
url: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const ConnectWidget: ({ containerSelector, iframeProps, onEvent, url, }: ConnectWidgetProps) => {
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,7 @@ const g = ({
|
|
|
4
4
|
onEvent: a,
|
|
5
5
|
url: o
|
|
6
6
|
}) => {
|
|
7
|
-
const t = document.createElement("iframe"), { style: c, ...d } = i || {}, m = {
|
|
8
|
-
height: "100%",
|
|
9
|
-
width: "100%",
|
|
10
|
-
...c ?? {}
|
|
11
|
-
};
|
|
7
|
+
const t = document.createElement("iframe"), { style: c, ...d } = i || {}, m = c || { height: "100%", width: "100%" };
|
|
12
8
|
Object.assign(t.style, m);
|
|
13
9
|
for (const [e, n] of Object.entries(d))
|
|
14
10
|
e.startsWith("data-") ? t.setAttribute(e, String(n)) : Object.assign(t, { [e]: n });
|
|
@@ -17,7 +13,7 @@ const g = ({
|
|
|
17
13
|
if (e.origin !== new URL(o).origin)
|
|
18
14
|
return;
|
|
19
15
|
const { data: n } = e, { metadata: f, type: u } = n;
|
|
20
|
-
a
|
|
16
|
+
a({
|
|
21
17
|
metadata: f,
|
|
22
18
|
type: u
|
|
23
19
|
});
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.index={}))})(this,(function(t){"use strict";const o=({containerSelector:s,iframeProps:a,onEvent:c,url:r})=>{const n=document.createElement("iframe"),{style:f,...u}=a||{},m={height:"100%",width:"100%"
|
|
1
|
+
(function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.index={}))})(this,(function(t){"use strict";const o=({containerSelector:s,iframeProps:a,onEvent:c,url:r})=>{const n=document.createElement("iframe"),{style:f,...u}=a||{},m=f||{height:"100%",width:"100%"};Object.assign(n.style,m);for(const[e,i]of Object.entries(u))e.startsWith("data-")?n.setAttribute(e,String(i)):Object.assign(n,{[e]:i});n.src=r;const d=e=>{if(e.origin!==new URL(r).origin)return;const{data:i}=e,{metadata:l,type:g}=i;c({metadata:l,type:g})};return{mount:()=>{const e=document.querySelector(s);if(!e)throw new Error(`Container with selector "${s}" not found.`);e.appendChild(n),window.addEventListener("message",d)},unmount:()=>{n.remove(),window.removeEventListener("message",d)}}};t.ConnectWidget=o,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|