@dora-cell/sdk-react 4.1.0 → 4.1.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 +42 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -6
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,8 +81,17 @@ A slide-over interface that handles the entire call lifecycle (Ringing, Connecti
|
|
|
81
81
|
> [!TIP]
|
|
82
82
|
> This component handles audio playback (remote stream and ringtones) automatically. You just need to ensure it's rendered in your tree when a call is active.
|
|
83
83
|
|
|
84
|
+
#### Props
|
|
85
|
+
|
|
86
|
+
- `isOpen?: boolean` - Controls if the interface is visible.
|
|
87
|
+
- `onOpenChange?: (open: boolean) => void` - Callback when the interface requests to open/close.
|
|
88
|
+
- `onCallEnded?: () => void` - Callback fired when a call ends.
|
|
89
|
+
- `maximizeIcon?: React.ReactNode` - Custom icon for the maximize button.
|
|
90
|
+
- `minimizeIcon?: React.ReactNode` - Custom icon for the minimize button.
|
|
91
|
+
|
|
84
92
|
```tsx
|
|
85
93
|
import { CallInterface } from "@dora-cell/sdk-react";
|
|
94
|
+
import { Maximize, Minimize2 } from "lucide-react";
|
|
86
95
|
|
|
87
96
|
function Dashboard() {
|
|
88
97
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -93,7 +102,13 @@ function Dashboard() {
|
|
|
93
102
|
This should be rendered globally (e.g., in your root layout)
|
|
94
103
|
to handle incoming calls even when the dialer is closed.
|
|
95
104
|
*/}
|
|
96
|
-
<CallInterface
|
|
105
|
+
<CallInterface
|
|
106
|
+
isOpen={isOpen}
|
|
107
|
+
onOpenChange={setIsOpen}
|
|
108
|
+
onCallEnded={() => console.log('Call ended')}
|
|
109
|
+
maximizeIcon={<Maximize size={18} />}
|
|
110
|
+
minimizeIcon={<Minimize2 size={16} />}
|
|
111
|
+
/>
|
|
97
112
|
</>
|
|
98
113
|
);
|
|
99
114
|
}
|
|
@@ -101,7 +116,32 @@ function Dashboard() {
|
|
|
101
116
|
|
|
102
117
|
### `Dialpad`
|
|
103
118
|
|
|
104
|
-
A flexible keypad for entering numbers and initiating calls. It automatically fetches available Caller IDs (extensions) and allows switching between them.
|
|
119
|
+
A flexible keypad for entering numbers and initiating calls. It automatically fetches available Caller IDs (extensions) and allows switching between them. If you prefer to manage the extensions in your own state, you can pass them as props.
|
|
120
|
+
|
|
121
|
+
#### Props
|
|
122
|
+
|
|
123
|
+
- `initialNumber?: string` - Pre-fill the dialpad input.
|
|
124
|
+
- `showKeys?: boolean` - Whether to show the numeric keypad by default (default: `true`).
|
|
125
|
+
- `className?: string` - Custom CSS classes for styling.
|
|
126
|
+
- `availableExtensions?: Array<{ label: string; value: string }>` - Override the automatically fetched caller IDs.
|
|
127
|
+
- `selectedExtension?: string` - Manually select the active caller ID.
|
|
128
|
+
- `onExtensionChange?: (ext: string) => void` - Callback fired when the user selects a different caller ID.
|
|
129
|
+
- `onCallInitiated?: (number: string) => void` - Callback fired right after a call starts.
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { Dialpad } from "@dora-cell/sdk-react";
|
|
133
|
+
|
|
134
|
+
function Dialer() {
|
|
135
|
+
return (
|
|
136
|
+
<Dialpad
|
|
137
|
+
initialNumber="+2348000000000"
|
|
138
|
+
showKeys={true}
|
|
139
|
+
className="my-custom-class"
|
|
140
|
+
onCallInitiated={(number) => console.log('Calling', number)}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
105
145
|
|
|
106
146
|
### `CreditBalance`
|
|
107
147
|
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -197,7 +197,8 @@ function CallInterface({
|
|
|
197
197
|
hangup,
|
|
198
198
|
answerCall,
|
|
199
199
|
toggleMute,
|
|
200
|
-
callError
|
|
200
|
+
callError,
|
|
201
|
+
isInitialized
|
|
201
202
|
} = useCall();
|
|
202
203
|
const [isMinimized, setIsMinimized] = react.useState(false);
|
|
203
204
|
const [wasConnected, setWasConnected] = react.useState(false);
|
|
@@ -387,8 +388,8 @@ function CallInterface({
|
|
|
387
388
|
] })
|
|
388
389
|
] }),
|
|
389
390
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-flex-1 dora-border-t dora-border-[#282828] dora-mt-2 dora-mb-2" }),
|
|
390
|
-
callError && callStatus === "ended" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-bg-red-900/20 dora-border dora-border-red-500/30 dora-rounded-lg dora-p-2 md:dora-p-3 dora-mb-2 md:dora-mb-3", children: [
|
|
391
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-red-400 dora-text-xs md:dora-text-sm dora-font-medium", children: "Call Failed" }),
|
|
391
|
+
callError && (callStatus === "ended" || !isInitialized) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-bg-red-900/20 dora-border dora-border-red-500/30 dora-rounded-lg dora-p-2 md:dora-p-3 dora-mb-2 md:dora-mb-3", children: [
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-red-400 dora-text-xs md:dora-text-sm dora-font-medium", children: !isInitialized ? "Configuration Error" : "Call Failed" }),
|
|
392
393
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-red-300 dora-text-xs dora-mt-0.5 md:dora-mt-1", children: callError }),
|
|
393
394
|
closeCountdown !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-mt-1.5 md:dora-mt-2", children: [
|
|
394
395
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-w-full dora-bg-red-900/30 dora-rounded-full dora-h-1.5 dora-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -446,7 +447,7 @@ function Dialpad({
|
|
|
446
447
|
selectedExtension: providedSelectedExtension,
|
|
447
448
|
onExtensionChange
|
|
448
449
|
}) {
|
|
449
|
-
const { call, callStatus } = useCall();
|
|
450
|
+
const { call, callStatus, callError, isInitialized } = useCall();
|
|
450
451
|
const { isConnected } = useConnectionStatus();
|
|
451
452
|
const { extensions: fetchedExtensions, setExtension } = useExtensions();
|
|
452
453
|
const [number, setNumber] = react.useState(initialNumber);
|
|
@@ -505,6 +506,13 @@ function Dialpad({
|
|
|
505
506
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-bg-emerald-500 dora-text-white dora-px-3 dora-py-1.5 dora-rounded-lg dora-text-xs md:dora-text-sm dora-font-semibold dora-shadow-sm", children: "Dora-cell" }),
|
|
506
507
|
/* @__PURE__ */ jsxRuntime.jsx(CreditBalance, {})
|
|
507
508
|
] }),
|
|
509
|
+
callError && !isInitialized && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-mb-4 dora-p-3 dora-bg-red-50 dora-border dora-border-red-100 dora-rounded-xl dora-flex dora-items-start dora-gap-3", children: [
|
|
510
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-w-5 dora-h-5 dora-rounded-full dora-bg-red-500 dora-flex-shrink-0 dora-flex dora-items-center dora-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(X, { size: 12, className: "dora-text-white" }) }),
|
|
511
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
512
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-xs dora-font-bold dora-text-red-700 dora-mt-0.5", children: "Configuration Error" }),
|
|
513
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-[11px] dora-text-red-600 dora-mt-0.5 dora-leading-tight", children: callError })
|
|
514
|
+
] })
|
|
515
|
+
] }),
|
|
508
516
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-bg-zinc-50 dora-p-6 dora-rounded-3xl dora-border dora-border-zinc-100 dora-shadow-inner", children: [
|
|
509
517
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-items-center dora-justify-between dora-mb-5", children: [
|
|
510
518
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-zinc-500 dora-font-medium dora-text-sm dora-tracking-tight", children: "Caller ID" }),
|
|
@@ -640,6 +648,8 @@ function DoraCellProvider({
|
|
|
640
648
|
}
|
|
641
649
|
if (state.error) {
|
|
642
650
|
setError(new Error(state.error));
|
|
651
|
+
} else if (state.status === "registered" || state.status === "connected" || state.status === "connecting") {
|
|
652
|
+
setError(null);
|
|
643
653
|
}
|
|
644
654
|
};
|
|
645
655
|
const handleIncomingCall = (call2) => {
|
|
@@ -770,7 +780,7 @@ function useDoraCell() {
|
|
|
770
780
|
return context;
|
|
771
781
|
}
|
|
772
782
|
function useCall() {
|
|
773
|
-
const { sdk, call, hangup, toggleMute, answerCall, callStatus, callDuration, isMuted, currentCall, error } = useDoraCell();
|
|
783
|
+
const { sdk, call, hangup, toggleMute, answerCall, callStatus, callDuration, isMuted, currentCall, error, isInitialized } = useDoraCell();
|
|
774
784
|
return {
|
|
775
785
|
sdk,
|
|
776
786
|
call,
|
|
@@ -781,7 +791,8 @@ function useCall() {
|
|
|
781
791
|
callDuration,
|
|
782
792
|
isMuted,
|
|
783
793
|
currentCall,
|
|
784
|
-
callError: error?.message
|
|
794
|
+
callError: error?.message,
|
|
795
|
+
isInitialized
|
|
785
796
|
};
|
|
786
797
|
}
|
|
787
798
|
function useConnectionStatus() {
|