@sawport/react-sdk 1.2.5-alpha.3 → 1.2.5-alpha.5

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 CHANGED
@@ -1,214 +1,263 @@
1
- # Getting Started With Sawport Widget
1
+ # Sawport Widget Integration Guide
2
+
3
+ ## Overview
4
+
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:
2
18
 
3
- ## Web Usage
4
- ### Pull the Sawport Widget CSS from your HTML head into your web page.
5
19
  ```html
6
- <html>
7
- <head>
8
- <link href="https://unpkg.com/@sawport/react-sdk/dist/style.css" rel="stylesheet" />
9
- ...
20
+ <link
21
+ href="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/react-sdk.css"
22
+ rel="stylesheet"
23
+ />
10
24
  ```
11
25
 
12
- ### Create a div with id of `sawport-widget` that will contain the widget.
26
+ ### 2.2 Create Widget Container & Mount the Widget
27
+ Place this immediately after the `<body>` tag:
28
+
13
29
  ```html
14
- ...
15
- <div id="sawport-widget"></div>
16
- </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>
17
52
  ```
18
53
 
19
- ### Pull in the sawport SDK into your website
20
- After pulling the sawport SDK
21
- Global variable `sawportSDK` will be exposed to your webpage which you can access its method and properties.
54
+ ### 2.3 Complete HTML Example
22
55
 
23
- **Important**: Use the `standalone` bundle for CDN usage to prevent React version conflicts:
24
56
  ```html
25
- ...
26
- <script type="module" src="https://unpkg.com/@sawport/react-sdk@latest/dist/index.standalone.js"></script>
27
- </body>
57
+ <!DOCTYPE html>
58
+ <html>
59
+ <head>
60
+ <link
61
+ href="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/react-sdk.css"
62
+ rel="stylesheet"
63
+ />
64
+ </head>
65
+
66
+ <body>
67
+ <!-- Your website content -->
68
+
69
+ <div
70
+ style="position: fixed; bottom: 20px; right: 20px; z-index: 200"
71
+ id="sawport-widget"
72
+ ></div>
73
+
74
+ <script src="https://cdn.jsdelivr.net/npm/@sawport/react-sdk/dist/index.standalone.js" type="text/javascript"></script>
75
+
76
+ <script type="text/javascript">
77
+ function docReady(fn) {
78
+ ['complete', 'interactive'].includes(document.readyState)
79
+ ? setTimeout(fn, 1)
80
+ : document.addEventListener('DOMContentLoaded', fn);
81
+ }
82
+
83
+ docReady(() => window.sawportReactSDK.mountWidget(
84
+ {
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
89
+ },
90
+ "sawport-widget"
91
+ ));
92
+ </script>
93
+ </body>
94
+ </html>
28
95
  ```
29
96
 
30
- ### Mount the sawport widget when document is fully loaded and with default configurations.
31
- Use the global `sawportSDK.mountWidget` to mount the widget anytime with the configuration it accepts
97
+ ### 2.4 Updating Enterprise Credentials Dynamically
98
+
32
99
  ```html
33
- ...
34
- <script>function docReady(fn) {
35
- ['complete', 'interactive'].includes(document.readyState)
36
- ? setTimeout(fn, 1)
37
- : document.addEventListener('DOMContentLoaded', fn);
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',
38
109
  }
39
-
40
- docReady(() => sawportSDK.mountWidget({
41
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
42
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
43
- projectId: XXXXXXXXXXXXXX,
44
- user: {email: 'example@emai.lcom', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}, // optional
45
- }, 'sawport-widget'))
46
- </script>
47
- </body>
110
+ });
111
+ </script>
48
112
  ```
49
113
 
50
- ### Setting up enterprise credentials
51
- Call the Sawport function `setSawportConfig` to set the enterprise credential.
52
- ```js
53
- docReady(() => sawportSDK.setSawportConfig({
54
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
55
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
56
- projectId: XXXXXXXXXXXXXX,
57
- user: {email: 'example@emai.lcom', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}
58
- })
59
- )
60
- ```
114
+ ## Using the Widget in ReactJS
115
+
116
+ ### 3.1 Install the SDK
61
117
 
62
- # Usage In REACTJS
63
- ## Install the SDK
64
118
  ```bash
65
119
  yarn add @sawport/react-sdk
66
120
  ```
67
121
 
68
- ## Configuring The Widget
69
- You may configure the widget by passing object of config to the `SawportContext.Provider`.
122
+ ### 3.2 Configure the SDK (Global Config)
123
+
124
+ Wrap your app with `SawportContext.Provider`:
125
+
70
126
  ```jsx
71
127
  import { SawportContext } from '@sawport/react-sdk';
72
128
 
73
129
  <SawportContext.Provider
74
- value={{
75
- config: {
76
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}', // required
77
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/', // required
78
- projectId: 'XXXXXXXXXXXXXX' // required
79
- }
80
- }}>
81
- <YourApp />
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 />
82
139
  </SawportContext.Provider>
83
140
  ```
84
- ## Using The Widget
141
+
142
+ ### 3.3 Using the Widget
143
+
85
144
  ```jsx
86
145
  import { Widget } from '@sawport/react-sdk';
87
146
 
88
- <Widget user={{email: 'example@emai.lcom', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}} />
147
+ <Widget
148
+ user={{
149
+ email: 'example@email.com',
150
+ mobile: '080XXXXXXXXX',
151
+ name: 'Firstname Lastname'
152
+ }}
153
+ />
89
154
  ```
90
155
 
91
- ## Updating SDK Configuration
156
+ ### 3.4 Updating Config at Runtime
157
+
92
158
  ```js
93
159
  import { setSawportConfig } from '@sawport/react-sdk';
94
160
 
95
161
  setSawportConfig({
96
- user: {email: 'example@emai.lcom', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'},
97
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}', // required
98
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/', // required
99
- projectId: 'XXXXXXXXXXXXXX' // required
100
- })
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
+ });
171
+ ```
172
+
173
+ ## Using the Widget in Vue.js
174
+
175
+ ### 4.1 Install the SDK
176
+
177
+ ```bash
178
+ yarn add @sawport/react-sdk
101
179
  ```
102
180
 
103
- # Usage In VUEJS
104
- ## Pull in Sawport SDK from the project's index.html
181
+ ### 4.2 Create Widget Mounting Point
182
+
105
183
  ```html
106
- <!DOCTYPE html>
107
- <html lang="en">
108
- <head>
109
- <meta charset="UTF-8">
110
- <link rel="icon" href="/favicon.ico">
111
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
112
- <title>Vite App</title>
113
- <!-- ADD SAWPORT SDK CSS -->
114
- <link href="https://unpkg.com/@sawport/react-sdk/dist/style.css" rel="stylesheet" />
115
- </head>
116
- <body>
117
- <div id="app"></div>
118
- <!-- CREATE A DIV TO HOLD SAWPORT WIDGET -->
119
- <div id="sawport-widget"></div>
120
- <!-- ADD SAWPORT SDK JS -->
121
- <script type="module" src="https://unpkg.com/@sawport/react-sdk@latest/dist/index.js"></script>
122
- <script type="module" src="/src/main.js"></script>
123
- </body>
124
- </html>
184
+ <div id="sawport-widget"></div>
125
185
  ```
126
186
 
127
- ## Mounting Sawport SDK From Your Vuejs APP
128
- You need to mount the widget from your vuejs app any time and any where.
129
- By pulling the Sawport SDK, `sawportSDK` variable would be exposed to your vuejs app globally.
187
+ ### 4.3 Mount Widget From Vue App
188
+
130
189
  ```vue
131
190
  <script setup>
191
+ import { onMounted } from 'vue'
192
+ import { mountWidget } from '@sawport/react-sdk'
132
193
  import HelloWorld from './components/HelloWorld.vue'
194
+ // import the SDK css styling
195
+ import '@sawport/react-sdk/dist/react-sdk.css'
133
196
 
134
- console.log({sawportSDK});
135
-
136
- const dashboardUrl = 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/'
197
+ const dashboardUrl = 'https://{DASHBOARD_HOST_DOMAIN}'
137
198
 
138
- // sawportSDK is globally accessible
139
- // Call Once
140
- sawportSDK.mountWidget({
141
- baseURL: dashboardUrl,
142
- apiURL: `${dashboardUrl}/api/v1/`,
143
- projectId: 'XXXXXXXXXXXXXX',
144
- user: {email: 'example@email.com', mobile: '2348123456789', name: 'Firstname Lastname'}, // optional
145
- }, 'sawport-widget')
199
+ onMounted(() => {
200
+ mountWidget({
201
+ baseURL: dashboardUrl,
202
+ apiURL: `${dashboardUrl}/api/v1/`,
203
+ projectId: 'XXXXXXXXXXXXXX',
204
+ user: {
205
+ email: 'example@email.com',
206
+ mobile: '2348123456789',
207
+ name: 'Firstname Lastname'
208
+ },
209
+ }, 'sawport-widget')
210
+ })
146
211
  </script>
147
212
 
148
213
  <template>
149
- <div class="wrapper">
150
- <!-- YOU MAY ADD DIV WITH ID ANYWHERE TO HOLD THE SAWPORT WIDGET -->
151
- <!-- <div id="sawport-widget"></div> -->
152
- <HelloWorld msg="You did it!" />
153
- </div>
214
+ <div class="wrapper">
215
+ <HelloWorld msg="You did it!" />
216
+ </div>
154
217
  </template>
155
218
  ```
156
219
 
157
- # API References `sawportSDK`
158
-
159
- ## Widget
160
- Sawport React SDK widget component
161
- ### Type
162
- - React Component
163
- ### Props
164
- - [user](#user)
165
- - [projectId](#projectid)
166
-
167
- ## SawportContext
168
- Sawport Context for global configuration of the widget
169
- ### Type
170
- - React Context Component
171
- ### Props
172
- #### value
173
- - [config](#sawportconfig)
174
- - [setConfig](#setsawportconfig)
175
-
176
- ## setSawportConfig
177
- ### Type
178
- - Function(config)
179
- ### Props
180
- - [config](#sawportconfig)
181
-
182
- ## sawportConfig
183
- The Sawport configuration object
184
- ### Type
185
- - Object
186
- ### user
187
- - name: `customer name to populate in the widget`
188
- - mobile: `customer phone number to populate in the widget`
189
- - email: `customer email to populate in the widget`
190
- ### projectId
191
- `The Enterprise's ID from the Dashboard`
192
-
193
- ## useSawportConfig
194
- The React hook to get access to the Sawport configuration object
195
- ### Type
196
- - React Hook - Function()
197
- ### Return
198
- - [config](#sawportconfig)
199
-
200
- ## useSawportContext
201
- React hook for Sawport Context for global configuration of the widget
202
- ### Type
203
- - React Context Hook - Function()
204
- ### Return
205
- - Sawport Context
206
- - - [config](#sawportconfig)
207
- - - [setConfig](#setsawportconfig)
208
-
209
- ## mountWidget
210
- Method to mount the Sawport SDK widget in HTML element with id of `sawport-widget`
211
- ### Type
212
- - Function(config)
213
- ### Props
214
- - [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.