@sawport/react-sdk 1.2.5-alpha.4 → 1.2.5-alpha.6
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 +182 -197
- package/dist/index.js +22752 -9933
- package/dist/index.standalone.js +8 -8
- package/dist/index.umd.js +8 -8
- package/dist/react-sdk.css +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,201 +1,198 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Sawport Widget Integration Guide
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Overview
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The Sawport Widget enables secure customer interactions—video calls, chat, document upload, and e-signature—embedded directly into your website or web application.
|
|
6
|
+
|
|
7
|
+
Available integrations:
|
|
8
|
+
- Web (CDN Embedded)
|
|
9
|
+
- React SDK
|
|
10
|
+
- Vue.js ES Module Integration
|
|
11
|
+
|
|
12
|
+
This guide provides configuration steps and usage examples for all supported platforms.
|
|
13
|
+
|
|
14
|
+
## Using Sawport Widget on the Web (CDN)
|
|
15
|
+
|
|
16
|
+
### 2.1 Add Required Scripts and Styles
|
|
17
|
+
Place this inside your HTML `<head>` tag:
|
|
7
18
|
|
|
8
19
|
```html
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"imports": {
|
|
14
|
-
"react": "https://esm.sh/react@19.1.1",
|
|
15
|
-
"react-dom": "https://esm.sh/react-dom@19.1.1"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
</script>
|
|
19
|
-
<link
|
|
20
|
-
href="https://esm.sh/@sawport/react-sdk/dist/react-sdk.css"
|
|
21
|
-
rel="stylesheet"
|
|
22
|
-
/>
|
|
23
|
-
</head>
|
|
20
|
+
<link
|
|
21
|
+
href="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/react-sdk.css"
|
|
22
|
+
rel="stylesheet"
|
|
23
|
+
/>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
###
|
|
27
|
-
|
|
26
|
+
### 2.2 Create Widget Container & Mount the Widget
|
|
27
|
+
Place this immediately after the `<body>` tag:
|
|
28
28
|
|
|
29
29
|
```html
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"sawport-widget"
|
|
53
|
-
))
|
|
54
|
-
</script>
|
|
55
|
-
</body>
|
|
30
|
+
<div style="position: fixed; bottom: 20px; right: 20px; z-index: 200" id="sawport-widget"></div>
|
|
31
|
+
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/index.standalone.js" type="text/javascript"></script>
|
|
33
|
+
|
|
34
|
+
<script type="text/javascript">
|
|
35
|
+
function docReady(fn) {
|
|
36
|
+
['complete', 'interactive'].includes(document.readyState)
|
|
37
|
+
? setTimeout(fn, 1)
|
|
38
|
+
: document.addEventListener('DOMContentLoaded', fn);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
docReady(() => window.sawportReactSDK.mountWidget(
|
|
42
|
+
{
|
|
43
|
+
baseURL: "https://{{BASE_URL}}",
|
|
44
|
+
apiURL: "https://{{BASE_URL}}/api/v1/",
|
|
45
|
+
projectId: "{{PROJECT_ID}}",
|
|
46
|
+
user: { email: 'example@email.com', mobile: '080XXXXXXXXX', name: 'Firstname Lastname' }, // optional
|
|
47
|
+
},
|
|
48
|
+
"sawport-widget"
|
|
49
|
+
));
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
56
52
|
```
|
|
57
53
|
|
|
58
|
-
### Complete Example
|
|
54
|
+
### 2.3 Complete HTML Example
|
|
55
|
+
|
|
59
56
|
```html
|
|
60
57
|
<!DOCTYPE html>
|
|
61
58
|
<html>
|
|
62
59
|
<head>
|
|
63
|
-
<script type="importmap">
|
|
64
|
-
{
|
|
65
|
-
"imports": {
|
|
66
|
-
"react": "https://esm.sh/react@19.1.1",
|
|
67
|
-
"react-dom": "https://esm.sh/react-dom@19.1.1"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
</script>
|
|
71
60
|
<link
|
|
72
|
-
href="https://
|
|
61
|
+
href="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/react-sdk.css"
|
|
73
62
|
rel="stylesheet"
|
|
74
63
|
/>
|
|
75
64
|
</head>
|
|
65
|
+
|
|
76
66
|
<body>
|
|
77
|
-
<!-- Your
|
|
78
|
-
|
|
79
|
-
<div
|
|
67
|
+
<!-- Your website content -->
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
style="position: fixed; bottom: 20px; right: 20px; z-index: 200"
|
|
71
|
+
id="sawport-widget"
|
|
72
|
+
></div>
|
|
80
73
|
|
|
81
|
-
<script type="
|
|
82
|
-
import {
|
|
83
|
-
mountWidget,
|
|
84
|
-
setSawportConfig,
|
|
85
|
-
} from "https://esm.sh/@sawport/react-sdk";
|
|
74
|
+
<script src="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/index.standalone.js" type="text/javascript"></script>
|
|
86
75
|
|
|
76
|
+
<script type="text/javascript">
|
|
87
77
|
function docReady(fn) {
|
|
88
78
|
['complete', 'interactive'].includes(document.readyState)
|
|
89
79
|
? setTimeout(fn, 1)
|
|
90
80
|
: document.addEventListener('DOMContentLoaded', fn);
|
|
91
81
|
}
|
|
92
|
-
|
|
93
|
-
docReady(() => mountWidget(
|
|
82
|
+
|
|
83
|
+
docReady(() => window.sawportReactSDK.mountWidget(
|
|
94
84
|
{
|
|
95
|
-
baseURL: "https://
|
|
96
|
-
apiURL: "https://
|
|
97
|
-
projectId: "
|
|
98
|
-
user: {email: 'example@email.com', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}, // optional
|
|
85
|
+
baseURL: "https://{{BASE_URL}}",
|
|
86
|
+
apiURL: "https://{{BASE_URL}}/api/v1/",
|
|
87
|
+
projectId: "{{PROJECT_ID}}",
|
|
88
|
+
user: { email: 'example@email.com', mobile: '080XXXXXXXXX', name: 'Firstname Lastname' }, // optional
|
|
99
89
|
},
|
|
100
90
|
"sawport-widget"
|
|
101
|
-
))
|
|
91
|
+
));
|
|
102
92
|
</script>
|
|
103
93
|
</body>
|
|
104
94
|
</html>
|
|
105
95
|
```
|
|
106
96
|
|
|
107
|
-
###
|
|
108
|
-
You can dynamically update the Sawport configuration using `setSawportConfig`:
|
|
109
|
-
```js
|
|
110
|
-
import { setSawportConfig } from "https://esm.sh/@sawport/react-sdk";
|
|
97
|
+
### 2.4 Updating Enterprise Credentials Dynamically
|
|
111
98
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
99
|
+
```html
|
|
100
|
+
<script type="text/javascript">
|
|
101
|
+
window.sawportReactSDK.setSawportConfig({
|
|
102
|
+
baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
|
|
103
|
+
apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
|
|
104
|
+
projectId: 'XXXXXXXXXXXXXX',
|
|
105
|
+
user: {
|
|
106
|
+
email: 'example@email.com',
|
|
107
|
+
mobile: '080XXXXXXXXX',
|
|
108
|
+
name: 'Firstname Lastname',
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
</script>
|
|
118
112
|
```
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
## Using the Widget in ReactJS
|
|
115
|
+
|
|
116
|
+
### 3.1 Install the SDK
|
|
117
|
+
|
|
122
118
|
```bash
|
|
123
119
|
yarn add @sawport/react-sdk
|
|
124
120
|
```
|
|
125
121
|
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
### 3.2 Configure the SDK (Global Config)
|
|
123
|
+
|
|
124
|
+
Wrap your app with `SawportContext.Provider`:
|
|
125
|
+
|
|
128
126
|
```jsx
|
|
129
127
|
import { SawportContext } from '@sawport/react-sdk';
|
|
130
128
|
|
|
131
129
|
<SawportContext.Provider
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
value={{
|
|
131
|
+
config: {
|
|
132
|
+
baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
|
|
133
|
+
apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
|
|
134
|
+
projectId: 'XXXXXXXXXXXXXX'
|
|
135
|
+
}
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
<YourApp />
|
|
140
139
|
</SawportContext.Provider>
|
|
141
140
|
```
|
|
142
|
-
|
|
141
|
+
|
|
142
|
+
### 3.3 Using the Widget
|
|
143
|
+
|
|
143
144
|
```jsx
|
|
144
145
|
import { Widget } from '@sawport/react-sdk';
|
|
145
146
|
|
|
146
|
-
<Widget
|
|
147
|
+
<Widget
|
|
148
|
+
user={{
|
|
149
|
+
email: 'example@email.com',
|
|
150
|
+
mobile: '080XXXXXXXXX',
|
|
151
|
+
name: 'Firstname Lastname'
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
147
154
|
```
|
|
148
155
|
|
|
149
|
-
|
|
156
|
+
### 3.4 Updating Config at Runtime
|
|
157
|
+
|
|
150
158
|
```js
|
|
151
159
|
import { setSawportConfig } from '@sawport/react-sdk';
|
|
152
160
|
|
|
153
161
|
setSawportConfig({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
162
|
+
user: {
|
|
163
|
+
email: 'example@email.com',
|
|
164
|
+
mobile: '080XXXXXXXXX',
|
|
165
|
+
name: 'Firstname Lastname'
|
|
166
|
+
},
|
|
167
|
+
baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
|
|
168
|
+
apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
|
|
169
|
+
projectId: 'XXXXXXXXXXXXXX'
|
|
170
|
+
});
|
|
159
171
|
```
|
|
160
172
|
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
## Using the Widget in Vue.js
|
|
174
|
+
|
|
175
|
+
### 4.1 Install the SDK
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
yarn add @sawport/react-sdk
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 4.2 Create Widget Mounting Point
|
|
182
|
+
|
|
163
183
|
```html
|
|
164
|
-
|
|
165
|
-
<html lang="en">
|
|
166
|
-
<head>
|
|
167
|
-
<meta charset="UTF-8">
|
|
168
|
-
<link rel="icon" href="/favicon.ico">
|
|
169
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
170
|
-
<title>Vite App</title>
|
|
171
|
-
<!-- ADD REACT IMPORTMAP -->
|
|
172
|
-
<script type="importmap">
|
|
173
|
-
{
|
|
174
|
-
"imports": {
|
|
175
|
-
"react": "https://esm.sh/react@19.1.1",
|
|
176
|
-
"react-dom": "https://esm.sh/react-dom@19.1.1"
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
</script>
|
|
180
|
-
<!-- ADD SAWPORT SDK CSS -->
|
|
181
|
-
<link href="https://esm.sh/@sawport/react-sdk/dist/react-sdk.css" rel="stylesheet" />
|
|
182
|
-
</head>
|
|
183
|
-
<body>
|
|
184
|
-
<div id="app"></div>
|
|
185
|
-
<!-- CREATE A DIV TO HOLD SAWPORT WIDGET -->
|
|
186
|
-
<div id="sawport-widget"></div>
|
|
187
|
-
<script type="module" src="/src/main.js"></script>
|
|
188
|
-
</body>
|
|
189
|
-
</html>
|
|
184
|
+
<div id="sawport-widget"></div>
|
|
190
185
|
```
|
|
191
186
|
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
### 4.3 Mount Widget From Vue App
|
|
188
|
+
|
|
194
189
|
```vue
|
|
195
190
|
<script setup>
|
|
196
191
|
import { onMounted } from 'vue'
|
|
197
|
-
import { mountWidget } from '
|
|
192
|
+
import { mountWidget } from '@sawport/react-sdk'
|
|
198
193
|
import HelloWorld from './components/HelloWorld.vue'
|
|
194
|
+
// import the SDK css styling
|
|
195
|
+
import '@sawport/react-sdk/dist/react-sdk.css'
|
|
199
196
|
|
|
200
197
|
const dashboardUrl = 'https://{DASHBOARD_HOST_DOMAIN}'
|
|
201
198
|
|
|
@@ -204,75 +201,63 @@ onMounted(() => {
|
|
|
204
201
|
baseURL: dashboardUrl,
|
|
205
202
|
apiURL: `${dashboardUrl}/api/v1/`,
|
|
206
203
|
projectId: 'XXXXXXXXXXXXXX',
|
|
207
|
-
user: {
|
|
204
|
+
user: {
|
|
205
|
+
email: 'example@email.com',
|
|
206
|
+
mobile: '2348123456789',
|
|
207
|
+
name: 'Firstname Lastname'
|
|
208
|
+
},
|
|
208
209
|
}, 'sawport-widget')
|
|
209
210
|
})
|
|
210
211
|
</script>
|
|
211
212
|
|
|
212
213
|
<template>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<HelloWorld msg="You did it!" />
|
|
217
|
-
</div>
|
|
214
|
+
<div class="wrapper">
|
|
215
|
+
<HelloWorld msg="You did it!" />
|
|
216
|
+
</div>
|
|
218
217
|
</template>
|
|
219
218
|
```
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
###
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-
|
|
243
|
-
|
|
244
|
-
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
###
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
##
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
-
|
|
261
|
-
|
|
262
|
-
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
React hook for Sawport Context for global configuration of the widget
|
|
266
|
-
### Type
|
|
267
|
-
- React Context Hook - Function()
|
|
268
|
-
### Return
|
|
269
|
-
- Sawport Context
|
|
270
|
-
- - [config](#sawportconfig)
|
|
271
|
-
- - [setConfig](#setsawportconfig)
|
|
272
|
-
|
|
273
|
-
## mountWidget
|
|
274
|
-
Method to mount the Sawport SDK widget in HTML element with id of `sawport-widget`
|
|
275
|
-
### Type
|
|
276
|
-
- Function(config)
|
|
277
|
-
### Props
|
|
278
|
-
- [config](#sawportconfig)
|
|
220
|
+
## API Reference: Sawport SDK
|
|
221
|
+
|
|
222
|
+
### 5.1 Widget Component
|
|
223
|
+
- React component for embedding the widget.
|
|
224
|
+
- Props:
|
|
225
|
+
- **user**: Customer information
|
|
226
|
+
- **projectId**: Enterprise ID
|
|
227
|
+
|
|
228
|
+
### 5.2 SawportContext
|
|
229
|
+
- Global configuration provider.
|
|
230
|
+
- Properties:
|
|
231
|
+
- **config**: Sawport configuration object
|
|
232
|
+
- **setConfig**: Update configuration
|
|
233
|
+
|
|
234
|
+
### 5.3 setSawportConfig
|
|
235
|
+
- Function for updating SDK config globally.
|
|
236
|
+
|
|
237
|
+
### 5.4 sawportConfig Object
|
|
238
|
+
- Fields:
|
|
239
|
+
- **user.name**: Customer name
|
|
240
|
+
- **user.mobile**: Customer phone number
|
|
241
|
+
- **user.email**: Customer email address
|
|
242
|
+
- **projectId**: Enterprise project ID
|
|
243
|
+
- **baseURL**: Dashboard domain
|
|
244
|
+
- **apiURL**: Dashboard API base
|
|
245
|
+
|
|
246
|
+
### 5.5 useSawportConfig
|
|
247
|
+
- React hook to access the config object.
|
|
248
|
+
|
|
249
|
+
### 5.6 useSawportContext
|
|
250
|
+
- Hook to retrieve both config and setConfig.
|
|
251
|
+
|
|
252
|
+
### 5.7 mountWidget
|
|
253
|
+
- Mounts SDK widget into a DOM element.
|
|
254
|
+
- Usage: `mountWidget(config, "sawport-widget")`
|
|
255
|
+
|
|
256
|
+
## Summary
|
|
257
|
+
|
|
258
|
+
This page provides a complete guide for integrating the Sawport Widget across:
|
|
259
|
+
- CDN-based web apps
|
|
260
|
+
- React apps
|
|
261
|
+
- Vue.js apps
|
|
262
|
+
|
|
263
|
+
It includes configuration references, usage patterns, and API documentation for all widget-related tools.
|