@dora-cell/sdk-react 0.1.1-beta.3 → 0.1.1-beta.7

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
@@ -22,6 +22,35 @@ pnpm add @dora-cell/sdk @dora-cell/sdk-react jssip
22
22
 
23
23
  ## Quick Start
24
24
 
25
+ ### Authentication
26
+
27
+ You can authenticate using either an API Token (recommended for production) or Direct SIP Credentials (useful for testing/development).
28
+
29
+ #### Option 1: API Token (Production)
30
+ The SDK will fetch SIP credentials from your backend using the token.
31
+ ```tsx
32
+ const config = {
33
+ auth: {
34
+ type: 'api-token',
35
+ apiToken: 'YOUR_API_TOKEN',
36
+ // apiBaseUrl: 'https://api.your-backend.com' (Optional)
37
+ }
38
+ };
39
+ ```
40
+
41
+ #### Option 2: Extension Authentication (Plug & Play)
42
+ You can connect using just your extension number. The SDK handles the server configuration automatically.
43
+
44
+ ```tsx
45
+ const config = {
46
+ auth: {
47
+ type: 'extension',
48
+ extension: '1000',
49
+ // password: '...' // Optional override (default: 1234)
50
+ }
51
+ };
52
+ ```
53
+
25
54
  ### 1. Wrap your app with DoraCellProvider
26
55
 
27
56
  ```tsx
@@ -191,6 +220,47 @@ sdk.on('call:incoming', (call) => {
191
220
  });
192
221
  ```
193
222
 
223
+ ### UI Components
224
+
225
+ The SDK includes pre-built UI components for typical call flows.
226
+
227
+ #### CallInterface
228
+ A complete active call modal that handles ringing, connecting, and ongoing call states.
229
+
230
+ ```tsx
231
+ import { CallInterface } from '@dora-cell/sdk-react';
232
+
233
+ function MyApp() {
234
+ const [isOpen, setIsOpen] = useState(false);
235
+
236
+ return (
237
+ <>
238
+ <CallInterface
239
+ isOpen={isOpen}
240
+ onOpenChange={setIsOpen}
241
+ onCallEnded={() => console.log('Call ended')}
242
+ />
243
+ </>
244
+ );
245
+ }
246
+ ```
247
+
248
+ #### Dialpad
249
+ A dialpad component for entering phone numbers and placing calls.
250
+
251
+ ```tsx
252
+ import { Dialpad } from '@dora-cell/sdk-react';
253
+
254
+ function MyApp() {
255
+ return (
256
+ <Dialpad
257
+ onCallInitiated={(number) => console.log('Calling:', number)}
258
+ initialNumber=""
259
+ />
260
+ );
261
+ }
262
+ ```
263
+
194
264
  ## Advanced Usage
195
265
 
196
266
  ### Handling Incoming Calls
package/dist/index.d.mts CHANGED
@@ -2,6 +2,56 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
3
  import { DoraCellConfig, CallStatus, Call, ConnectionStatus, DoraCell } from '@dora-cell/sdk';
4
4
 
5
+ interface CallInterfaceProps {
6
+ /**
7
+ * Whether the interface is open/visible
8
+ */
9
+ isOpen?: boolean;
10
+ /**
11
+ * Callback when visibility changes
12
+ */
13
+ onOpenChange?: (open: boolean) => void;
14
+ /**
15
+ * Callback when call ends (useful for invalidating queries)
16
+ */
17
+ onCallEnded?: () => void;
18
+ /**
19
+ * Custom maximize icon component
20
+ */
21
+ maximizeIcon?: React.ReactNode;
22
+ /**
23
+ * Custom minimize icon component
24
+ */
25
+ minimizeIcon?: React.ReactNode;
26
+ }
27
+ declare function CallInterface({ isOpen, onOpenChange, onCallEnded, maximizeIcon, minimizeIcon, }: CallInterfaceProps): react_jsx_runtime.JSX.Element | null;
28
+
29
+ interface DialpadProps {
30
+ /**
31
+ * Callback when call is initiated
32
+ */
33
+ onCallInitiated?: (number: string) => void;
34
+ /**
35
+ * Initial number to populate
36
+ */
37
+ initialNumber?: string;
38
+ /**
39
+ * Whether to show the dialpad keys (0-9)
40
+ */
41
+ showKeys?: boolean;
42
+ /**
43
+ * Custom class name for the container
44
+ */
45
+ className?: string;
46
+ availableExtensions?: Array<{
47
+ label: string;
48
+ value: string;
49
+ }>;
50
+ selectedExtension?: string;
51
+ onExtensionChange?: (ext: string) => void;
52
+ }
53
+ declare function Dialpad({ onCallInitiated, initialNumber, showKeys, className, availableExtensions, selectedExtension, onExtensionChange, }: DialpadProps): react_jsx_runtime.JSX.Element;
54
+
5
55
  interface DoraCellContextValue {
6
56
  sdk: DoraCell | null;
7
57
  connectionStatus: ConnectionStatus;
@@ -33,6 +83,7 @@ declare function useCall(): {
33
83
  call: (phoneNumber: string, extension?: string) => Promise<void>;
34
84
  hangup: () => void;
35
85
  toggleMute: () => void;
86
+ answerCall: () => void;
36
87
  callStatus: CallStatus;
37
88
  callDuration: string;
38
89
  isMuted: boolean;
@@ -48,4 +99,4 @@ declare function useConnectionStatus(): {
48
99
  error: Error | null;
49
100
  };
50
101
 
51
- export { DoraCellProvider, type DoraCellProviderProps, useCall, useConnectionStatus, useDoraCell };
102
+ export { CallInterface, Dialpad, DoraCellProvider, type DoraCellProviderProps, useCall, useConnectionStatus, useDoraCell };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,56 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
3
  import { DoraCellConfig, CallStatus, Call, ConnectionStatus, DoraCell } from '@dora-cell/sdk';
4
4
 
5
+ interface CallInterfaceProps {
6
+ /**
7
+ * Whether the interface is open/visible
8
+ */
9
+ isOpen?: boolean;
10
+ /**
11
+ * Callback when visibility changes
12
+ */
13
+ onOpenChange?: (open: boolean) => void;
14
+ /**
15
+ * Callback when call ends (useful for invalidating queries)
16
+ */
17
+ onCallEnded?: () => void;
18
+ /**
19
+ * Custom maximize icon component
20
+ */
21
+ maximizeIcon?: React.ReactNode;
22
+ /**
23
+ * Custom minimize icon component
24
+ */
25
+ minimizeIcon?: React.ReactNode;
26
+ }
27
+ declare function CallInterface({ isOpen, onOpenChange, onCallEnded, maximizeIcon, minimizeIcon, }: CallInterfaceProps): react_jsx_runtime.JSX.Element | null;
28
+
29
+ interface DialpadProps {
30
+ /**
31
+ * Callback when call is initiated
32
+ */
33
+ onCallInitiated?: (number: string) => void;
34
+ /**
35
+ * Initial number to populate
36
+ */
37
+ initialNumber?: string;
38
+ /**
39
+ * Whether to show the dialpad keys (0-9)
40
+ */
41
+ showKeys?: boolean;
42
+ /**
43
+ * Custom class name for the container
44
+ */
45
+ className?: string;
46
+ availableExtensions?: Array<{
47
+ label: string;
48
+ value: string;
49
+ }>;
50
+ selectedExtension?: string;
51
+ onExtensionChange?: (ext: string) => void;
52
+ }
53
+ declare function Dialpad({ onCallInitiated, initialNumber, showKeys, className, availableExtensions, selectedExtension, onExtensionChange, }: DialpadProps): react_jsx_runtime.JSX.Element;
54
+
5
55
  interface DoraCellContextValue {
6
56
  sdk: DoraCell | null;
7
57
  connectionStatus: ConnectionStatus;
@@ -33,6 +83,7 @@ declare function useCall(): {
33
83
  call: (phoneNumber: string, extension?: string) => Promise<void>;
34
84
  hangup: () => void;
35
85
  toggleMute: () => void;
86
+ answerCall: () => void;
36
87
  callStatus: CallStatus;
37
88
  callDuration: string;
38
89
  isMuted: boolean;
@@ -48,4 +99,4 @@ declare function useConnectionStatus(): {
48
99
  error: Error | null;
49
100
  };
50
101
 
51
- export { DoraCellProvider, type DoraCellProviderProps, useCall, useConnectionStatus, useDoraCell };
102
+ export { CallInterface, Dialpad, DoraCellProvider, type DoraCellProviderProps, useCall, useConnectionStatus, useDoraCell };