sonic-widget 1.20.0 → 1.22.0
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 +76 -4
- package/dist/{sonic-widget.umd.js → index.js} +2168 -2137
- package/package.json +3 -16
- package/dist/sonic-widget.mjs +0 -118227
package/README.md
CHANGED
|
@@ -2,11 +2,83 @@
|
|
|
2
2
|
|
|
3
3
|
**Sonic Widget** - _used to show the onboard kyc at your web page itself._
|
|
4
4
|
|
|
5
|
-
Use this script tag to get access to the widget
|
|
5
|
+
Use this script tag to get access to the widget:
|
|
6
6
|
|
|
7
|
-
**_`<script src="https://cdn.jsdelivr.net/npm/sonic-widget@1.
|
|
7
|
+
**_`<script src="https://cdn.jsdelivr.net/npm/sonic-widget@1.22.0/dist/index.min.js"></script>`_**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
or in **Angular** can be used by installing package from npm
|
|
10
|
+
|
|
11
|
+
**_`npm install sonic-widget`_**`
|
|
12
|
+
|
|
13
|
+
and adding path in `angular.json`
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
17
|
+
```
|
|
18
|
+
## Implementation Details for Angular TypeScript:
|
|
19
|
+
|
|
20
|
+
**Steps:-**
|
|
21
|
+
|
|
22
|
+
1. Create or open an angular TS project.
|
|
23
|
+
|
|
24
|
+
2. Use this script tag to get access to the widget at initial html page:
|
|
25
|
+
|
|
26
|
+
**_`<script src="https://cdn.jsdelivr.net/npm/sonic-widget@1.22.0/dist/index.min.js"></script>`_**
|
|
27
|
+
|
|
28
|
+
or it can be added in `angular.json` by installing the npm package
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. At `app.component.html`, Add a button with the id **`xxxx`**. It is used to call the widget by on click event.
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<button id="xxxx">Open</button>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. Add a div tag with the id **`sonic-web-widget`** at the specific place. It is used to display the sonic module with the help of this id.
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<div id="sonic-web-widget"></div>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. Add a declaration for var *sonic* at TS file `app.component.ts`.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
declare var sonic: any;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
5. Next, add the functionality to call widget in the base of onInit.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
ngOnInit(): void {
|
|
56
|
+
|
|
57
|
+
const config = {
|
|
58
|
+
baseurl: string, // the base url of the backend server
|
|
59
|
+
showPage: boolean, // used to show the page or not
|
|
60
|
+
ipInfoKey: string, // api key to detect vpn used or not from "ipInfo.io"
|
|
61
|
+
videoURL: string, // url of video to do (e.g: demo doing kyc)
|
|
62
|
+
accountId: string, // account can be taken from operator axiom account
|
|
63
|
+
userId: string, // user prospective data
|
|
64
|
+
userName: string, // user prospective data
|
|
65
|
+
email: string, // user prospective data
|
|
66
|
+
phone: string, // user prospective data
|
|
67
|
+
applicationNo: string, // user prospective data
|
|
68
|
+
isMalay: boolean, //used to change the default language english to malay
|
|
69
|
+
onMessage: function (data) {}, // callback function, when api response message or error or any other actions
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// get the element used in the action button
|
|
73
|
+
var container = document.getElementById('xxxx');
|
|
74
|
+
// on click of element widget works
|
|
75
|
+
container?.addEventListener('click', function () {
|
|
76
|
+
sonic?.SonicWidget(config);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Implementation Details for Vanilla JavaScript:
|
|
10
82
|
|
|
11
83
|
**Steps:-**
|
|
12
84
|
|
|
@@ -27,7 +99,7 @@ Use this script tag to get access to the widget.
|
|
|
27
99
|
4. Add a Script tag to the head tag or body tag. And use the latest version.
|
|
28
100
|
|
|
29
101
|
```html
|
|
30
|
-
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@1.
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@1.22.0/dist/index.min.js"></script>
|
|
31
103
|
```
|
|
32
104
|
|
|
33
105
|
5. Next, add the script tag at a necessary place. But add below the widget script.
|