@sawport/react-sdk 1.2.5-beta.2 → 1.2.5-beta.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 CHANGED
@@ -1,201 +1,198 @@
1
- # Getting Started With Sawport Widget
1
+ # Sawport Widget Integration Guide
2
2
 
3
- ## Web Usage (CDN)
3
+ ## Overview
4
4
 
5
- ### Step 1: Add Required Scripts and Styles to HTML Head
6
- Add the React importmap and Sawport widget CSS to your HTML `<head>` tag:
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
- <html>
10
- <head>
11
- <script type="importmap">
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
- ### Step 2: Create Widget Container and Mount Script
27
- Add the widget container and mounting script after the `<body>` tag:
26
+ ### 2.2 Create Widget Container & Mount the Widget
27
+ Place this immediately after the `<body>` tag:
28
28
 
29
29
  ```html
30
- <body>
31
- <div style="position: fixed; bottom: 20px; right: 20px; z-index: 200" id="sawport-widget"></div>
32
-
33
- <script type="module">
34
- import {
35
- mountWidget,
36
- setSawportConfig,
37
- } from "https://esm.sh/@sawport/react-sdk";
38
-
39
- function docReady(fn) {
40
- ['complete', 'interactive'].includes(document.readyState)
41
- ? setTimeout(fn, 1)
42
- : document.addEventListener('DOMContentLoaded', fn);
43
- }
44
-
45
- docReady(() => mountWidget(
46
- {
47
- baseURL: "https://{{BASE_URL}}",
48
- apiURL: "https://{{BASE_URL}}/api/v1/",
49
- projectId: "{{PROJECT_ID}}",
50
- user: {email: 'example@email.com', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}, // optional
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://esm.sh/@sawport/react-sdk/dist/react-sdk.css"
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 page content -->
78
-
79
- <div style="position: fixed; bottom: 20px; right: 20px; z-index: 200" id="sawport-widget"></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="module">
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://your-dashboard-domain.com",
96
- apiURL: "https://your-dashboard-domain.com/api/v1/",
97
- projectId: "your-project-id",
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
- ### Setting up enterprise credentials
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
- setSawportConfig({
113
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
114
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
115
- projectId: 'XXXXXXXXXXXXXX',
116
- user: {email: 'example@email.com', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'}
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
- # Usage In REACTJS
121
- ## Install the SDK
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
- ## Configuring The Widget
127
- 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
+
128
126
  ```jsx
129
127
  import { SawportContext } from '@sawport/react-sdk';
130
128
 
131
129
  <SawportContext.Provider
132
- value={{
133
- config: {
134
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}', // required
135
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/', // required
136
- projectId: 'XXXXXXXXXXXXXX' // required
137
- }
138
- }}>
139
- <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 />
140
139
  </SawportContext.Provider>
141
140
  ```
142
- ## Using The Widget
141
+
142
+ ### 3.3 Using the Widget
143
+
143
144
  ```jsx
144
145
  import { Widget } from '@sawport/react-sdk';
145
146
 
146
- <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
+ />
147
154
  ```
148
155
 
149
- ## Updating SDK Configuration
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
- user: {email: 'example@emai.lcom', mobile: '080XXXXXXXXX', name: 'Firstname Lastname'},
155
- baseURL: 'https://{DASHBOARD_HOST_DOMAIN}', // required
156
- apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/', // required
157
- projectId: 'XXXXXXXXXXXXXX' // required
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
- # Usage In VUEJS
162
- ## Pull in Sawport SDK from the project's index.html
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
- <!DOCTYPE html>
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
- ## Mounting Sawport SDK From Your Vue.js APP
193
- You need to mount the widget from your Vue.js app. Import the SDK functions directly using ES modules.
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 'https://esm.sh/@sawport/react-sdk'
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: {email: 'example@email.com', mobile: '2348123456789', name: 'Firstname Lastname'}, // optional
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
- <div class="wrapper">
214
- <!-- YOU MAY ADD DIV WITH ID ANYWHERE TO HOLD THE SAWPORT WIDGET -->
215
- <!-- <div id="sawport-widget"></div> -->
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
- # API References `sawportSDK`
222
-
223
- ## Widget
224
- Sawport React SDK widget component
225
- ### Type
226
- - React Component
227
- ### Props
228
- - [user](#user)
229
- - [projectId](#projectid)
230
-
231
- ## SawportContext
232
- Sawport Context for global configuration of the widget
233
- ### Type
234
- - React Context Component
235
- ### Props
236
- #### value
237
- - [config](#sawportconfig)
238
- - [setConfig](#setsawportconfig)
239
-
240
- ## setSawportConfig
241
- ### Type
242
- - Function(config)
243
- ### Props
244
- - [config](#sawportconfig)
245
-
246
- ## sawportConfig
247
- The Sawport configuration object
248
- ### Type
249
- - Object
250
- ### user
251
- - name: `customer name to populate in the widget`
252
- - mobile: `customer phone number to populate in the widget`
253
- - email: `customer email to populate in the widget`
254
- ### projectId
255
- `The Enterprise's ID from the Dashboard`
256
-
257
- ## useSawportConfig
258
- The React hook to get access to the Sawport configuration object
259
- ### Type
260
- - React Hook - Function()
261
- ### Return
262
- - [config](#sawportconfig)
263
-
264
- ## useSawportContext
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.