call-control-sdk 1.0.0 → 2.0.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/dist/index.d.mts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +630 -0
- package/dist/index.mjs +634 -0
- package/package.json +10 -21
- package/eslint.config.js +0 -23
- package/index.html +0 -13
- package/public/vite.svg +0 -1
- package/src/App.tsx +0 -47
- package/src/index.css +0 -23
- package/src/lib/components/CallControlPanel.tsx +0 -422
- package/src/lib/hooks/useDraggable.ts +0 -128
- package/src/lib/hooks/useSDKState.ts +0 -17
- package/src/lib/index.ts +0 -25
- package/src/lib/sdk-state.ts +0 -140
- package/src/lib/types.ts +0 -22
- package/src/main.tsx +0 -10
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -27
- package/tsconfig.json +0 -7
- package/tsconfig.lib.json +0 -23
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -47
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Call Control SDK</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/public/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/src/App.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { Box } from "@mui/material";
|
|
3
|
-
import { CallControlPanel, initCallSDK, updateCallData } from "./lib";
|
|
4
|
-
|
|
5
|
-
function App() {
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
// Initialize the SDK with a test API key
|
|
8
|
-
try {
|
|
9
|
-
initCallSDK("test-api-key-12345");
|
|
10
|
-
console.log("SDK initialized successfully");
|
|
11
|
-
|
|
12
|
-
// Simulate some call data
|
|
13
|
-
updateCallData({
|
|
14
|
-
mobileNumber: "+1-234-567-8900",
|
|
15
|
-
callReferenceId: "CALL-REF-001",
|
|
16
|
-
agentLoginId: "AGENT-123",
|
|
17
|
-
});
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error("SDK initialization failed:", error);
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
const handleDataChange = (data: {
|
|
24
|
-
mobileNumber: string;
|
|
25
|
-
callReferenceId: string;
|
|
26
|
-
agentLoginId: string;
|
|
27
|
-
}) => {
|
|
28
|
-
console.log("Call data changed:", data);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Box>
|
|
33
|
-
<h1
|
|
34
|
-
style={{
|
|
35
|
-
color: "#1976d2",
|
|
36
|
-
marginBottom: "20px",
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
Call Control SDK Demo
|
|
40
|
-
</h1>
|
|
41
|
-
|
|
42
|
-
<CallControlPanel onDataChange={handleDataChange} />
|
|
43
|
-
</Box>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default App;
|
package/src/index.css
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
-
line-height: 1.5;
|
|
4
|
-
font-weight: 400;
|
|
5
|
-
width: 100%;
|
|
6
|
-
color-scheme: light dark;
|
|
7
|
-
color: rgba(255, 255, 255, 0.87);
|
|
8
|
-
background-color: #f3f3f3;
|
|
9
|
-
|
|
10
|
-
font-synthesis: none;
|
|
11
|
-
text-rendering: optimizeLegibility;
|
|
12
|
-
-webkit-font-smoothing: antialiased;
|
|
13
|
-
-moz-osx-font-smoothing: grayscale;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
body {
|
|
18
|
-
margin: 0;
|
|
19
|
-
display: flex;
|
|
20
|
-
width: 100%;
|
|
21
|
-
min-height: 100vh;
|
|
22
|
-
}
|
|
23
|
-
|
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Paper,
|
|
4
|
-
IconButton,
|
|
5
|
-
Typography,
|
|
6
|
-
Menu,
|
|
7
|
-
MenuItem,
|
|
8
|
-
Box,
|
|
9
|
-
Tooltip,
|
|
10
|
-
Fade,
|
|
11
|
-
useTheme,
|
|
12
|
-
Button,
|
|
13
|
-
} from "@mui/material";
|
|
14
|
-
import {
|
|
15
|
-
PauseCircle,
|
|
16
|
-
PlayCircle,
|
|
17
|
-
Mic,
|
|
18
|
-
MicOff,
|
|
19
|
-
MoreVert,
|
|
20
|
-
CallEnd,
|
|
21
|
-
KeyboardArrowDown,
|
|
22
|
-
Cached,
|
|
23
|
-
FreeBreakfast,
|
|
24
|
-
AirlineSeatIndividualSuite,
|
|
25
|
-
TransferWithinAStation,
|
|
26
|
-
Groups,
|
|
27
|
-
Phone,
|
|
28
|
-
DragIndicator,
|
|
29
|
-
SpatialAudioOff,
|
|
30
|
-
} from "@mui/icons-material";
|
|
31
|
-
import { useSDKState } from "../hooks/useSDKState";
|
|
32
|
-
import { useDraggable } from "../hooks/useDraggable";
|
|
33
|
-
import { sdkStateManager } from "../sdk-state";
|
|
34
|
-
import type { CallControlPanelProps, CallStatus } from "../types";
|
|
35
|
-
|
|
36
|
-
export function CallControlPanel({ onDataChange }: CallControlPanelProps) {
|
|
37
|
-
const theme = useTheme();
|
|
38
|
-
const state = useSDKState();
|
|
39
|
-
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
40
|
-
const [moreOptionsAnchorEl, setMoreOptionsAnchorEl] =
|
|
41
|
-
useState<null | HTMLElement>(null);
|
|
42
|
-
const [callDuration, setCallDuration] = useState(0);
|
|
43
|
-
|
|
44
|
-
const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } =
|
|
45
|
-
useDraggable(state.position, (newPosition) =>
|
|
46
|
-
sdkStateManager.setPosition(newPosition)
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Call duration timer
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
let interval: NodeJS.Timeout;
|
|
52
|
-
|
|
53
|
-
if (state.callStartTime) {
|
|
54
|
-
interval = setInterval(() => {
|
|
55
|
-
const elapsed = Math.floor((Date.now() - state.callStartTime!) / 1000);
|
|
56
|
-
setCallDuration(elapsed);
|
|
57
|
-
}, 1000);
|
|
58
|
-
} else {
|
|
59
|
-
setCallDuration(0);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return () => {
|
|
63
|
-
if (interval) clearInterval(interval);
|
|
64
|
-
};
|
|
65
|
-
}, [state.callStartTime]);
|
|
66
|
-
|
|
67
|
-
// Notify parent of data changes
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (onDataChange) {
|
|
70
|
-
onDataChange(state.callData);
|
|
71
|
-
}
|
|
72
|
-
}, [state.callData, onDataChange]);
|
|
73
|
-
|
|
74
|
-
const formatDuration = useCallback((seconds: number): string => {
|
|
75
|
-
const mins = Math.floor(seconds / 60);
|
|
76
|
-
const secs = seconds % 60;
|
|
77
|
-
return `${mins.toString().padStart(2, "0")}:${secs
|
|
78
|
-
.toString()
|
|
79
|
-
.padStart(2, "0")}`;
|
|
80
|
-
}, []);
|
|
81
|
-
|
|
82
|
-
const getStatusColor = useCallback((status: CallStatus) => {
|
|
83
|
-
switch (status) {
|
|
84
|
-
case "ready":
|
|
85
|
-
return "success";
|
|
86
|
-
case "break":
|
|
87
|
-
return "warning";
|
|
88
|
-
case "idle":
|
|
89
|
-
return "default";
|
|
90
|
-
default:
|
|
91
|
-
return "default";
|
|
92
|
-
}
|
|
93
|
-
}, []);
|
|
94
|
-
|
|
95
|
-
const handleHoldToggle = () => {
|
|
96
|
-
sdkStateManager.setHolding(!state.isHolding);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const handleMuteToggle = () => {
|
|
100
|
-
sdkStateManager.setMuted(!state.isMuted);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const handleStatusChange = (newStatus: CallStatus) => {
|
|
104
|
-
sdkStateManager.setStatus(newStatus);
|
|
105
|
-
setAnchorEl(null);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const handleEndCall = () => {
|
|
109
|
-
sdkStateManager.endCall();
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const handleStartCall = () => {
|
|
113
|
-
sdkStateManager.startCall();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const handleMoreClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
117
|
-
setAnchorEl(event.currentTarget);
|
|
118
|
-
};
|
|
119
|
-
const handleMoreOptions = (event: React.MouseEvent<HTMLElement>) => {
|
|
120
|
-
setMoreOptionsAnchorEl(event.currentTarget);
|
|
121
|
-
};
|
|
122
|
-
const handleMoreClose = () => {
|
|
123
|
-
setAnchorEl(null);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const handleMoreOptionsClose = () => {
|
|
127
|
-
setMoreOptionsAnchorEl(null);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// if (!state.isInitialized) {
|
|
131
|
-
// return (
|
|
132
|
-
// <Paper
|
|
133
|
-
// elevation={2}
|
|
134
|
-
// sx={{
|
|
135
|
-
// position: "fixed",
|
|
136
|
-
// top: "50%",
|
|
137
|
-
// left: "50%",
|
|
138
|
-
// transform: "translate(-50%, -50%)",
|
|
139
|
-
// p: 2,
|
|
140
|
-
// borderRadius: 2,
|
|
141
|
-
// bgcolor: "error.light",
|
|
142
|
-
// color: "error.contrastText",
|
|
143
|
-
// zIndex: 9999,
|
|
144
|
-
// }}
|
|
145
|
-
// >
|
|
146
|
-
// <Typography variant="h6" gutterBottom>
|
|
147
|
-
// SDK Error
|
|
148
|
-
// </Typography>
|
|
149
|
-
// <Typography variant="body2">
|
|
150
|
-
// Call SDK not initialized. Please call initCallSDK() first.
|
|
151
|
-
// </Typography>
|
|
152
|
-
// </Paper>
|
|
153
|
-
// );
|
|
154
|
-
// }
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<>
|
|
158
|
-
<Fade in={true} timeout={300}>
|
|
159
|
-
<Paper
|
|
160
|
-
ref={dragRef}
|
|
161
|
-
elevation={isDragging ? 2 : 1}
|
|
162
|
-
sx={{
|
|
163
|
-
position: "fixed",
|
|
164
|
-
left: position.x,
|
|
165
|
-
top: position.y,
|
|
166
|
-
p: 1,
|
|
167
|
-
borderRadius: 3,
|
|
168
|
-
bgcolor: "background.paper",
|
|
169
|
-
cursor: isDragging ? "grabbing" : "grab",
|
|
170
|
-
transition: theme.transitions.create(["box-shadow", "transform"], {
|
|
171
|
-
duration: theme.transitions.duration.short,
|
|
172
|
-
}),
|
|
173
|
-
transform: isDragging ? "scale(1.01)" : "scale(1)",
|
|
174
|
-
minWidth: 320,
|
|
175
|
-
userSelect: "none",
|
|
176
|
-
}}
|
|
177
|
-
onMouseDown={handleMouseDown}
|
|
178
|
-
onTouchStart={handleTouchStart}
|
|
179
|
-
>
|
|
180
|
-
<Box
|
|
181
|
-
sx={{
|
|
182
|
-
display: "flex",
|
|
183
|
-
alignItems: "center",
|
|
184
|
-
}}
|
|
185
|
-
>
|
|
186
|
-
{/* Status and Timer Row */}
|
|
187
|
-
<Box
|
|
188
|
-
sx={{
|
|
189
|
-
display: "flex",
|
|
190
|
-
justifyContent: "space-between",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
}}
|
|
193
|
-
>
|
|
194
|
-
<Typography
|
|
195
|
-
variant="h6"
|
|
196
|
-
sx={{
|
|
197
|
-
color: state.callStartTime
|
|
198
|
-
? "success.main"
|
|
199
|
-
: "text.secondary",
|
|
200
|
-
marginRight: "8px",
|
|
201
|
-
display: "flex",
|
|
202
|
-
justifyContent: "space-between",
|
|
203
|
-
alignItems: "center",
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
<DragIndicator
|
|
207
|
-
sx={{
|
|
208
|
-
marginRight: "10px",
|
|
209
|
-
}}
|
|
210
|
-
/>{" "}
|
|
211
|
-
{formatDuration(callDuration)}
|
|
212
|
-
</Typography>
|
|
213
|
-
|
|
214
|
-
<Tooltip title="Status">
|
|
215
|
-
<Button
|
|
216
|
-
sx={{
|
|
217
|
-
backgroundColor: getStatusColor(state.status),
|
|
218
|
-
fontWeight: "bold",
|
|
219
|
-
borderRadius: "16px",
|
|
220
|
-
display: "flex",
|
|
221
|
-
alignItems: "center",
|
|
222
|
-
justifyContent: "space-between",
|
|
223
|
-
marginRight: "8px",
|
|
224
|
-
}}
|
|
225
|
-
onClick={(e) => {
|
|
226
|
-
e.stopPropagation();
|
|
227
|
-
handleMoreClick(e);
|
|
228
|
-
}}
|
|
229
|
-
variant="outlined"
|
|
230
|
-
>
|
|
231
|
-
<Typography
|
|
232
|
-
width={50}
|
|
233
|
-
variant="body2"
|
|
234
|
-
sx={{
|
|
235
|
-
fontWeight: "bold",
|
|
236
|
-
}}
|
|
237
|
-
>
|
|
238
|
-
{state.status.toUpperCase()}
|
|
239
|
-
</Typography>
|
|
240
|
-
|
|
241
|
-
<KeyboardArrowDown />
|
|
242
|
-
</Button>
|
|
243
|
-
</Tooltip>
|
|
244
|
-
</Box>
|
|
245
|
-
|
|
246
|
-
{/* Control Buttons */}
|
|
247
|
-
<Box
|
|
248
|
-
sx={{
|
|
249
|
-
display: "flex",
|
|
250
|
-
gap: 1,
|
|
251
|
-
justifyContent: "center",
|
|
252
|
-
alignItems: "center",
|
|
253
|
-
}}
|
|
254
|
-
>
|
|
255
|
-
<Tooltip title={"Redial"}>
|
|
256
|
-
<IconButton
|
|
257
|
-
onClick={(e) => {
|
|
258
|
-
e.stopPropagation();
|
|
259
|
-
}}
|
|
260
|
-
color={"default"}
|
|
261
|
-
sx={{
|
|
262
|
-
bgcolor: "action.hover",
|
|
263
|
-
"&:hover": {
|
|
264
|
-
bgcolor: "warning",
|
|
265
|
-
},
|
|
266
|
-
}}
|
|
267
|
-
>
|
|
268
|
-
<Cached />
|
|
269
|
-
</IconButton>
|
|
270
|
-
</Tooltip>
|
|
271
|
-
{/* Hold Button */}
|
|
272
|
-
<Tooltip title={state.isHolding ? "Resume" : "Hold"}>
|
|
273
|
-
<IconButton
|
|
274
|
-
onClick={(e) => {
|
|
275
|
-
e.stopPropagation();
|
|
276
|
-
handleHoldToggle();
|
|
277
|
-
}}
|
|
278
|
-
color={state.isHolding ? "warning" : "default"}
|
|
279
|
-
sx={{
|
|
280
|
-
bgcolor: state.isHolding ? "warning.info" : "action.hover",
|
|
281
|
-
}}
|
|
282
|
-
>
|
|
283
|
-
{state.isHolding ? <PlayCircle /> : <PauseCircle />}
|
|
284
|
-
</IconButton>
|
|
285
|
-
</Tooltip>
|
|
286
|
-
|
|
287
|
-
{/* Mute Button */}
|
|
288
|
-
<Tooltip title={state.isMuted ? "Unmute" : "Mute"}>
|
|
289
|
-
<IconButton
|
|
290
|
-
onClick={(e) => {
|
|
291
|
-
e.stopPropagation();
|
|
292
|
-
handleMuteToggle();
|
|
293
|
-
}}
|
|
294
|
-
color={state.isMuted ? "error" : "default"}
|
|
295
|
-
sx={{
|
|
296
|
-
bgcolor: state.isMuted ? "error.info" : "action.hover",
|
|
297
|
-
}}
|
|
298
|
-
>
|
|
299
|
-
{state.isMuted ? <MicOff /> : <Mic />}
|
|
300
|
-
</IconButton>
|
|
301
|
-
</Tooltip>
|
|
302
|
-
|
|
303
|
-
{/* More Menu Button */}
|
|
304
|
-
<Tooltip title="More Options">
|
|
305
|
-
<IconButton
|
|
306
|
-
onClick={(e) => {
|
|
307
|
-
e.stopPropagation();
|
|
308
|
-
handleMoreOptions(e);
|
|
309
|
-
}}
|
|
310
|
-
sx={{
|
|
311
|
-
bgcolor: "action.hover",
|
|
312
|
-
"&:hover": { bgcolor: "action.selected" },
|
|
313
|
-
}}
|
|
314
|
-
>
|
|
315
|
-
<MoreVert />
|
|
316
|
-
</IconButton>
|
|
317
|
-
</Tooltip>
|
|
318
|
-
|
|
319
|
-
{/* End Call Button */}
|
|
320
|
-
<Tooltip title={state.callStartTime ? "End Call" : "Start Call"}>
|
|
321
|
-
<IconButton
|
|
322
|
-
onClick={(e) => {
|
|
323
|
-
e.stopPropagation();
|
|
324
|
-
(state.callStartTime ? handleEndCall : handleStartCall)();
|
|
325
|
-
}}
|
|
326
|
-
color="error"
|
|
327
|
-
sx={{
|
|
328
|
-
bgcolor: state.callStartTime
|
|
329
|
-
? "error.main"
|
|
330
|
-
: "success.light",
|
|
331
|
-
color: "white",
|
|
332
|
-
"&:hover": {
|
|
333
|
-
bgcolor: state.callStartTime
|
|
334
|
-
? "error.light"
|
|
335
|
-
: "success.dark",
|
|
336
|
-
},
|
|
337
|
-
}}
|
|
338
|
-
>
|
|
339
|
-
<CallEnd />
|
|
340
|
-
</IconButton>
|
|
341
|
-
</Tooltip>
|
|
342
|
-
</Box>
|
|
343
|
-
</Box>
|
|
344
|
-
</Paper>
|
|
345
|
-
</Fade>
|
|
346
|
-
|
|
347
|
-
{/* More Options Menu */}
|
|
348
|
-
<Menu
|
|
349
|
-
anchorEl={anchorEl}
|
|
350
|
-
open={Boolean(anchorEl)}
|
|
351
|
-
onClose={handleMoreClose}
|
|
352
|
-
onClick={(e) => e.stopPropagation()}
|
|
353
|
-
>
|
|
354
|
-
<MenuItem
|
|
355
|
-
onClick={() => handleStatusChange("ready")}
|
|
356
|
-
sx={{
|
|
357
|
-
backgroundColor: state.status === "ready" ? "#0038f01c" : "initial",
|
|
358
|
-
}}
|
|
359
|
-
>
|
|
360
|
-
<Box
|
|
361
|
-
sx={{
|
|
362
|
-
display: "flex",
|
|
363
|
-
alignItems: "center",
|
|
364
|
-
gap: 1,
|
|
365
|
-
}}
|
|
366
|
-
>
|
|
367
|
-
<Phone color="success" />
|
|
368
|
-
<Typography>Ready</Typography>
|
|
369
|
-
</Box>
|
|
370
|
-
</MenuItem>
|
|
371
|
-
<MenuItem
|
|
372
|
-
onClick={() => handleStatusChange("break")}
|
|
373
|
-
sx={{
|
|
374
|
-
backgroundColor: state.status === "break" ? "#0038f01c" : "initial",
|
|
375
|
-
}}
|
|
376
|
-
>
|
|
377
|
-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
378
|
-
<FreeBreakfast color="error" />
|
|
379
|
-
<Typography>Break</Typography>
|
|
380
|
-
</Box>
|
|
381
|
-
</MenuItem>
|
|
382
|
-
<MenuItem
|
|
383
|
-
onClick={() => handleStatusChange("idle")}
|
|
384
|
-
sx={{
|
|
385
|
-
backgroundColor: state.status === "idle" ? "#0038f01c" : "initial",
|
|
386
|
-
}}
|
|
387
|
-
>
|
|
388
|
-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
389
|
-
<AirlineSeatIndividualSuite color="warning" />
|
|
390
|
-
<Typography>Idle</Typography>
|
|
391
|
-
</Box>
|
|
392
|
-
</MenuItem>
|
|
393
|
-
</Menu>
|
|
394
|
-
|
|
395
|
-
<Menu
|
|
396
|
-
anchorEl={moreOptionsAnchorEl}
|
|
397
|
-
open={Boolean(moreOptionsAnchorEl)}
|
|
398
|
-
onClose={handleMoreOptionsClose}
|
|
399
|
-
onClick={(e) => e.stopPropagation()}
|
|
400
|
-
>
|
|
401
|
-
<MenuItem onClick={() => setMoreOptionsAnchorEl(null)}>
|
|
402
|
-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
403
|
-
<TransferWithinAStation color="secondary" />
|
|
404
|
-
<Typography>Call Transfer</Typography>
|
|
405
|
-
</Box>
|
|
406
|
-
</MenuItem>
|
|
407
|
-
<MenuItem onClick={() => setMoreOptionsAnchorEl(null)}>
|
|
408
|
-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
409
|
-
<Groups color="secondary" />
|
|
410
|
-
<Typography>Conference Call</Typography>
|
|
411
|
-
</Box>
|
|
412
|
-
</MenuItem>
|
|
413
|
-
<MenuItem onClick={() => setMoreOptionsAnchorEl(null)}>
|
|
414
|
-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
415
|
-
<SpatialAudioOff color="secondary" />
|
|
416
|
-
<Typography>Queue Waiting</Typography>
|
|
417
|
-
</Box>
|
|
418
|
-
</MenuItem>
|
|
419
|
-
</Menu>
|
|
420
|
-
</>
|
|
421
|
-
);
|
|
422
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useState,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
type MouseEvent,
|
|
6
|
-
type TouchEvent,
|
|
7
|
-
} from "react";
|
|
8
|
-
|
|
9
|
-
interface Position {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface UseDraggableReturn {
|
|
15
|
-
position: Position;
|
|
16
|
-
isDragging: boolean;
|
|
17
|
-
dragRef: React.RefObject<HTMLDivElement | null>;
|
|
18
|
-
handleMouseDown: (e: MouseEvent<HTMLDivElement>) => void;
|
|
19
|
-
handleTouchStart: (e: TouchEvent<HTMLDivElement>) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useDraggable(
|
|
23
|
-
initialPosition: Position,
|
|
24
|
-
onPositionChange?: (position: Position) => void
|
|
25
|
-
): UseDraggableReturn {
|
|
26
|
-
const [position, setPosition] = useState<Position>(initialPosition);
|
|
27
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
28
|
-
const dragRef = useRef<HTMLDivElement>(null);
|
|
29
|
-
const dragStart = useRef<Position>({ x: 0, y: 0 });
|
|
30
|
-
const elementStart = useRef<Position>({ x: 0, y: 0 });
|
|
31
|
-
|
|
32
|
-
const updatePosition = useCallback(
|
|
33
|
-
(newPosition: Position) => {
|
|
34
|
-
// Constrain position to viewport bounds
|
|
35
|
-
const element = dragRef.current;
|
|
36
|
-
if (!element) return;
|
|
37
|
-
|
|
38
|
-
const rect = element.getBoundingClientRect();
|
|
39
|
-
const viewportWidth = window.innerWidth;
|
|
40
|
-
const viewportHeight = window.innerHeight;
|
|
41
|
-
|
|
42
|
-
const constrainedPosition = {
|
|
43
|
-
x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
|
|
44
|
-
y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height)),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
setPosition(constrainedPosition);
|
|
48
|
-
onPositionChange?.(constrainedPosition);
|
|
49
|
-
},
|
|
50
|
-
[onPositionChange]
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const handleStart = useCallback(
|
|
54
|
-
(clientX: number, clientY: number) => {
|
|
55
|
-
setIsDragging(true);
|
|
56
|
-
dragStart.current = { x: clientX, y: clientY };
|
|
57
|
-
elementStart.current = position;
|
|
58
|
-
|
|
59
|
-
const handleMove = (moveClientX: number, moveClientY: number) => {
|
|
60
|
-
const deltaX = moveClientX - dragStart.current.x;
|
|
61
|
-
const deltaY = moveClientY - dragStart.current.y;
|
|
62
|
-
|
|
63
|
-
const newPosition = {
|
|
64
|
-
x: elementStart.current.x + deltaX,
|
|
65
|
-
y: elementStart.current.y + deltaY,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
updatePosition(newPosition);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const handleMouseMove = (e: globalThis.MouseEvent) => {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
handleMove(e.clientX, e.clientY);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const handleTouchMove = (e: globalThis.TouchEvent) => {
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
const touch = e.touches[0];
|
|
79
|
-
if (touch) {
|
|
80
|
-
handleMove(touch.clientX, touch.clientY);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const handleEnd = () => {
|
|
85
|
-
setIsDragging(false);
|
|
86
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
87
|
-
document.removeEventListener("mouseup", handleEnd);
|
|
88
|
-
document.removeEventListener("touchmove", handleTouchMove);
|
|
89
|
-
document.removeEventListener("touchend", handleEnd);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
93
|
-
document.addEventListener("mouseup", handleEnd);
|
|
94
|
-
document.addEventListener("touchmove", handleTouchMove, {
|
|
95
|
-
passive: false,
|
|
96
|
-
});
|
|
97
|
-
document.addEventListener("touchend", handleEnd);
|
|
98
|
-
},
|
|
99
|
-
[position, updatePosition]
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const handleMouseDown = useCallback(
|
|
103
|
-
(e: MouseEvent<HTMLDivElement>) => {
|
|
104
|
-
e.preventDefault();
|
|
105
|
-
handleStart(e.clientX, e.clientY);
|
|
106
|
-
},
|
|
107
|
-
[handleStart]
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const handleTouchStart = useCallback(
|
|
111
|
-
(e: TouchEvent<HTMLDivElement>) => {
|
|
112
|
-
e.preventDefault();
|
|
113
|
-
const touch = e.touches[0];
|
|
114
|
-
if (touch) {
|
|
115
|
-
handleStart(touch.clientX, touch.clientY);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
[handleStart]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
position,
|
|
123
|
-
isDragging,
|
|
124
|
-
dragRef,
|
|
125
|
-
handleMouseDown,
|
|
126
|
-
handleTouchStart,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { sdkStateManager } from "../sdk-state";
|
|
3
|
-
import type { SDKState } from "../types";
|
|
4
|
-
|
|
5
|
-
export function useSDKState(): SDKState {
|
|
6
|
-
const [state, setState] = useState<SDKState>(sdkStateManager.getState());
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const unsubscribe = sdkStateManager.subscribe(() => {
|
|
10
|
-
setState(sdkStateManager.getState());
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return unsubscribe;
|
|
14
|
-
}, []);
|
|
15
|
-
|
|
16
|
-
return state;
|
|
17
|
-
}
|
package/src/lib/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { sdkStateManager } from './sdk-state';
|
|
2
|
-
|
|
3
|
-
export { CallControlPanel } from './components/CallControlPanel';
|
|
4
|
-
export type { CallControlPanelProps, CallData, CallStatus } from './types';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Initialize the Call Control SDK with an API key
|
|
8
|
-
* @param sdkApiKey - The API key for SDK authentication
|
|
9
|
-
* @throws {Error} When API key is missing or invalid
|
|
10
|
-
*/
|
|
11
|
-
export function initCallSDK(sdkApiKey: string): void {
|
|
12
|
-
sdkStateManager.initialize(sdkApiKey);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Update call data (used by host application)
|
|
17
|
-
* @param data - Partial call data to update
|
|
18
|
-
*/
|
|
19
|
-
export function updateCallData(data: {
|
|
20
|
-
mobileNumber?: string;
|
|
21
|
-
callReferenceId?: string;
|
|
22
|
-
agentLoginId?: string;
|
|
23
|
-
}): void {
|
|
24
|
-
sdkStateManager.updateCallData(data);
|
|
25
|
-
}
|