Commit 8f82117d authored by Muhammadali's avatar Muhammadali

update verison: 0.8.3

parent 360f0efa
{ {
"name": "boxdialer", "name": "boxdialer",
"version": "0.8.2", "version": "0.8.3",
"description": "", "description": "",
"main": "src/boxDialer.js", "main": "src/boxDialer.js",
"scripts": { "scripts": {
......
/** @format */
import React from 'react';
import BxMiniWidjetUiStyle, { DialPadIcon } from './style';
import TimerUi from '../TimerUi';
const BxMiniWidjetUi = ({
widjetState,
phoneNumber,
reason,
widjetVersion,
leftTime,
onClick,
position,
}) => {
return (
<BxMiniWidjetUiStyle
status={widjetState}
onClick={onClick}
position={position}>
<div className='left'>
<p className='title'>{phoneNumber}</p>
<p>
<span className='status'>{widjetState}</span>
<TimerUi reason={reason} time={leftTime} />
</p>
</div>
<div className='bottom'>
<BxMiniWidjetUiStyle.StatusLine status={widjetState}>
<p className='verison'>v {widjetVersion}</p>
</BxMiniWidjetUiStyle.StatusLine>
</div>
</BxMiniWidjetUiStyle>
);
};
export default BxMiniWidjetUi;
/** @format */
import styled from 'styled-components';
import CallIcon from '@mui/icons-material/Dialpad';
import { boxDialerWidjetPosition } from '../../lib/boxDialerWidjetPosition';
const BxMiniWidjetUiStyle = styled.div`
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
height: 70px;
width: 80px;
border-radius: 13px;
background-color: #164e63e6;
cursor: pointer;
color: white;
z-index: 999;
position: fixed;
display: grid;
align-items: center;
grid-template-columns: 1fr;
grid-template-rows: 1fr 10px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
${({ position }) => boxDialerWidjetPosition[position].block}
.left {
display: flex;
flex-direction: column;
align-items: center;
}
.right {
}
.title {
font-size: 20px;
font-weight: 600;
}
.bottom {
height: 100%;
grid-column: 1/3;
grid-row: 2/3;
}
.status {
border-radius: 10px;
padding: 0 3px;
margin: 0 5px;
font-size: 12px;
background-color: ${({ status }) =>
status === 'pending'
? 'orange'
: status === 'connected'
? '#a0c13d'
: '#ccc'};
color: ${({ status }) =>
status === 'pending' ? '#fff' : status === 'connected' ? '#333' : '#ccc'};
}
`;
BxMiniWidjetUiStyle.StatusLine = styled.div`
height: 100%;
background-color: ${({ backColor }) => backColor};
border-bottom-left-radius: 30px;
border-bottom-right-radius: 30px;
background-color: ${({ status }) =>
status === 'pending'
? 'orange'
: status === 'connected'
? '#a0c13d'
: '#ccc'};
display: flex;
align-items: center;
justify-content: flex-end;
padding: 0 10px 0 0;
color: green;
.verison {
font-size: 10px;
font-weight: bold;
float: right;
}
`;
const DialPadIcon = styled(CallIcon)`
font-size: 26px;
`;
export { DialPadIcon };
export default BxMiniWidjetUiStyle;
...@@ -4,16 +4,20 @@ import React from 'react'; ...@@ -4,16 +4,20 @@ import React from 'react';
import DefaultWidjetStyle, { DialPadIcon } from './style'; import DefaultWidjetStyle, { DialPadIcon } from './style';
import TimerUi from '../TimerUi'; import TimerUi from '../TimerUi';
const DefaultWidjet = ({ const DefaultWidjetUi = ({
widjetState, widjetState,
phoneNumber, phoneNumber,
reason, reason,
widjetVersion, widjetVersion,
leftTime, leftTime,
onClick, onClick,
position,
}) => { }) => {
return ( return (
<DefaultWidjetStyle status={widjetState} onClick={onClick}> <DefaultWidjetStyle
status={widjetState}
onClick={onClick}
position={position}>
<div className='left'> <div className='left'>
<p className='title'>{phoneNumber}</p> <p className='title'>{phoneNumber}</p>
<p> <p>
...@@ -33,4 +37,4 @@ const DefaultWidjet = ({ ...@@ -33,4 +37,4 @@ const DefaultWidjet = ({
); );
}; };
export default DefaultWidjet; export default DefaultWidjetUi;
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import styled from 'styled-components'; import styled from 'styled-components';
import CallIcon from '@mui/icons-material/Dialpad'; import CallIcon from '@mui/icons-material/Dialpad';
import { boxDialerWidjetPosition } from '../../lib/boxDialerWidjetPosition';
const DefaultWidjetStyle = styled.div` const DefaultWidjetStyle = styled.div`
* { * {
...@@ -20,9 +21,7 @@ const DefaultWidjetStyle = styled.div` ...@@ -20,9 +21,7 @@ const DefaultWidjetStyle = styled.div`
z-index: 999; z-index: 999;
position: fixed; position: fixed;
bottom: 30px; ${({ position }) => boxDialerWidjetPosition[position].block}
left: 50px;
display: grid; display: grid;
align-items: center; align-items: center;
grid-template-columns: 1fr 30px; grid-template-columns: 1fr 30px;
......
/** @format */ /** @format */
import React, {useCallback, useEffect, useState} from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import ModalPhoneNumpadStyle, {NumberButton, Input} from './style' import ModalPhoneNumpadStyle, { NumberButton, Input } from './style';
import numbers from "./numbers" import numbers from './numbers';
import DropDownTailwind from "../TailwindComponents/DropDown" import DropDownTailwind from '../TailwindComponents/DropDown';
import CallIcon from "@mui/icons-material/Call" import CallIcon from '@mui/icons-material/Call';
import {toast} from "react-hot-toast" import { toast } from 'react-hot-toast';
const ModalPhoneNumpad = ({ const ModalPhoneNumpad = ({
phoneModal, phoneModal,
...@@ -13,28 +13,27 @@ const ModalPhoneNumpad = ({ ...@@ -13,28 +13,27 @@ const ModalPhoneNumpad = ({
reasons, reasons,
reason, reason,
onSetDnd, onSetDnd,
dynamicValue dynamicValue,
position,
}) => { }) => {
const boxDialer = window.BoxDialer; const boxDialer = window.BoxDialer;
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
useEffect(() => { useEffect(() => {
if (!modalState.bool) setInputValue(''); if (!modalState.bool) setInputValue('');
}, [modalState.bool]); }, [modalState.bool]);
const inputController = ({ value, type, from }) => {
const inputController = ({value, type, from}) => { boxDialer.onSoundType({ type: 'pick', bool: true });
boxDialer.onSoundType({type: 'pick', bool: true});
if (modalState.callType === 'outcoming' && modalState.bool) { if (modalState.callType === 'outcoming' && modalState.bool) {
boxDialer.sipSendDTMF(value); boxDialer.sipSendDTMF(value);
} }
switch (type) { switch (type) {
case 'add': case 'add':
if (value.match(/^[a-zA-Z0-9!@#\$%\^\&*\)\(+=._-]+$/g).join('').length) { if (
value.match(/^[a-zA-Z0-9!@#\$%\^\&*\)\(+=._-]+$/g).join('').length
) {
if (from === 'input') return setInputValue(value); if (from === 'input') return setInputValue(value);
if (from === 'button') setInputValue(inputValue + value); if (from === 'button') setInputValue(inputValue + value);
} }
...@@ -42,10 +41,12 @@ const ModalPhoneNumpad = ({ ...@@ -42,10 +41,12 @@ const ModalPhoneNumpad = ({
break; break;
case 'delete': case 'delete':
if (from === 'button') { if (from === 'button') {
setInputValue(inputValue setInputValue(
inputValue
.split('') .split('')
.slice(0, inputValue.length - 1) .slice(0, inputValue.length - 1)
.join(''),); .join(''),
);
} }
if (from === 'input') { if (from === 'input') {
setInputValue(value); setInputValue(value);
...@@ -63,7 +64,7 @@ const ModalPhoneNumpad = ({ ...@@ -63,7 +64,7 @@ const ModalPhoneNumpad = ({
navigator.clipboard navigator.clipboard
.readText() .readText()
.then((text) => { .then((text) => {
inputController({type: 'add', value: text, from: 'button'}); inputController({ type: 'add', value: text, from: 'button' });
}) })
.catch((err) => { .catch((err) => {
console.log('Something went wrong', err); console.log('Something went wrong', err);
...@@ -76,17 +77,28 @@ const ModalPhoneNumpad = ({ ...@@ -76,17 +77,28 @@ const ModalPhoneNumpad = ({
toggleCP: (e) => { toggleCP: (e) => {
if (phoneModal && (modalState.bool ? false : true) && e.key === 'Enter') { if (phoneModal && (modalState.bool ? false : true) && e.key === 'Enter') {
boxDialer.initialized(inputValue); boxDialer.initialized(inputValue);
} else if (phoneModal && (modalState.bool ? false : true) && e.key === 'Backspace') { } else if (
inputController({type: 'delete', from: 'button', value: e.value}); phoneModal &&
} else if (phoneModal && (modalState.bool ? false : true) && !isNaN(+e.key)) { (modalState.bool ? false : true) &&
inputController({type: 'add', value: e.key, from: 'button'}); e.key === 'Backspace'
) {
inputController({ type: 'delete', from: 'button', value: e.value });
} else if (
phoneModal &&
(modalState.bool ? false : true) &&
!isNaN(+e.key)
) {
inputController({ type: 'add', value: e.key, from: 'button' });
} }
}, },
}; };
const handleKeyUp = useCallback((event) => { const handleKeyUp = useCallback(
(event) => {
console.log(event); console.log(event);
gameState.toggleCP(event); gameState.toggleCP(event);
}, [gameState.toggleCP],); },
[gameState.toggleCP],
);
useEffect(() => { useEffect(() => {
document.addEventListener('keyup', handleKeyUp); document.addEventListener('keyup', handleKeyUp);
...@@ -110,15 +122,14 @@ const ModalPhoneNumpad = ({ ...@@ -110,15 +122,14 @@ const ModalPhoneNumpad = ({
return ( return (
<ModalPhoneNumpadStyle <ModalPhoneNumpadStyle
position={position}
hidden={!phoneModal} hidden={!phoneModal}
onClick={(e) => e.stopPropagation()}> onClick={(e) => e.stopPropagation()}>
<ModalPhoneNumpadStyle.InputArea> <ModalPhoneNumpadStyle.InputArea>
<Input disabled type='text' value={inputValue} /> <Input disabled type='text' value={inputValue} />
{inputValue.length ? ( {inputValue.length ? (
<Input.BackSpaceIcon <Input.BackSpaceIcon
onClick={() => onClick={() => inputController({ type: 'delete', from: 'button' })}
inputController({ type: 'delete', from: 'button' })
}
/> />
) : ( ) : (
'' ''
......
import styled from 'styled-components' /** @format */
import KeyboardBackspaceIcon from "@mui/icons-material/KeyboardBackspace"
import styled from 'styled-components';
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace';
import { boxDialerWidjetPosition } from '../../lib/boxDialerWidjetPosition';
const ModalPhoneNumpadStyle = styled.div` const ModalPhoneNumpadStyle = styled.div`
width: 230px; width: 230px;
...@@ -7,8 +10,11 @@ const ModalPhoneNumpadStyle = styled.div` ...@@ -7,8 +10,11 @@ const ModalPhoneNumpadStyle = styled.div`
bottom: 120px; bottom: 120px;
transition: 0.2s; transition: 0.2s;
z-index: 999; z-index: 999;
transform: translate(${({hidden}) => (hidden ? '-300px' : '325px')}, 0%); ${({ hidden, position }) =>
left: -300px; hidden
? boxDialerWidjetPosition[position].numpad.hidden
: boxDialerWidjetPosition[position].numpad.seen}
background-color: #c9d5d9; background-color: #c9d5d9;
border-radius: 20px; border-radius: 20px;
padding: 15px; padding: 15px;
...@@ -80,13 +86,16 @@ const NumberButton = styled.div` ...@@ -80,13 +86,16 @@ const NumberButton = styled.div`
font-size: 22px; font-size: 22px;
cursor: pointer; cursor: pointer;
height: 33px; height: 33px;
background-color: ${({ background-color: ${({ status, type }) =>
status, type type === 'call_button'
}) => type === 'call_button' ? status === 'pending' ? 'orange' : status === 'connected' && '#a0c13d' : '#5e5e5e'}; ? status === 'pending'
? 'orange'
: status === 'connected' && '#a0c13d'
: '#5e5e5e'};
`; `;
NumberButton.Icon = styled.div` NumberButton.Icon = styled.div`
font-size: 20px; font-size: 20px;
`; `;
export {NumberButton, Input} export { NumberButton, Input };
export default ModalPhoneNumpadStyle export default ModalPhoneNumpadStyle;
/** @format */
export const boxDialerWidjetPosition = {
bottomLeft: {
block: {
bottom: '30px',
left: '50px',
},
numpad: {
hidden: {
left: '-300px',
},
seen: {
left: '25px',
},
},
},
bottomCenter: {
block: {
transform: 'translate(-50%, 0)',
bottom: '30px',
left: '50%',
},
numpad: {
hidden: {
bottom: '-300px',
left: '50%',
transform: 'translate(-50%, 0)',
},
seen: {
bottom: '120px',
left: '50%',
transform: 'translate(-50%, 0)',
},
},
},
bottomRight: {
block: {
bottom: '30px',
left: 'auto',
right: '50px',
},
numpad: {
hidden: {
left: 'auto',
right: '-300px',
},
seen: {
left: 'auto',
right: '25px',
},
},
},
};
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
import WidjetButton from '../components/WidjetButton'; import WidjetButton from '../components/WidjetButton';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import packageJson from '../../package.json'; import packageJson from '../../package.json';
import DefaultWidjet from '../components/DefaultWidjetUi'; import DefaultWidjetUi from '../components/DefaultWidjetUi';
import ModalPhoneNumpad from '../components/ModalPhoneNumpad'; import ModalPhoneNumpad from '../components/ModalPhoneNumpad';
import Modal from '../components/Modal'; import Modal from '../components/Modal';
import BxMiniWidjetUi from '../components/BxMiniWidjetUi';
const Root = ({ data, onSetDnd, position }) => { const Root = ({ data, onSetDnd }) => {
if (!data) { if (!data) {
data = { data = {
iscloud: true, iscloud: true,
...@@ -19,6 +20,7 @@ const Root = ({ data, onSetDnd, position }) => { ...@@ -19,6 +20,7 @@ const Root = ({ data, onSetDnd, position }) => {
lefttime: 231461, lefttime: 231461,
reasons: ['free', 'outcalls', 'home', 'totop'], reasons: ['free', 'outcalls', 'home', 'totop'],
variant: 'bxmini', variant: 'bxmini',
position: 'bottomRight',
}; };
} }
...@@ -45,20 +47,50 @@ const Root = ({ data, onSetDnd, position }) => { ...@@ -45,20 +47,50 @@ const Root = ({ data, onSetDnd, position }) => {
boxDialer.hangupButtonClick(); boxDialer.hangupButtonClick();
}; };
if (!data || !data?.number) return; const selectWidjetType = (type) => {
switch (type) {
case 'bxmini':
return ( return (
<> <BxMiniWidjetUi
<DefaultWidjet widjetState={dynamicValue}
phoneNumber={data?.number}
reason={data?.reason}
widjetVersion={packageJson?.version}
leftTime={data.lefttime}
position={data.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
/>
);
default:
return (
<DefaultWidjetUi
widjetState={dynamicValue} widjetState={dynamicValue}
phoneNumber={data?.number} phoneNumber={data?.number}
reason={data?.reason} reason={data?.reason}
widjetVersion={packageJson?.version} widjetVersion={packageJson?.version}
leftTime={data.lefttime} leftTime={data.lefttime}
position={data.position || 'bottomLeft'}
onClick={() => { onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true); phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}} }}
/> />
);
}
};
if (
!data ||
!data?.number
// || !data?.position
)
return;
return (
<>
{selectWidjetType(data.variant)}
<ModalPhoneNumpad <ModalPhoneNumpad
modalState={modalState} modalState={modalState}
phoneModal={phoneModal} phoneModal={phoneModal}
...@@ -67,7 +99,9 @@ const Root = ({ data, onSetDnd, position }) => { ...@@ -67,7 +99,9 @@ const Root = ({ data, onSetDnd, position }) => {
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue} dynamicValue={dynamicValue}
onSetDnd={onSetDnd} onSetDnd={onSetDnd}
position={data.position || 'bottomLeft'}
/> />
<Modal <Modal
className='tailwindGlobalCss' className='tailwindGlobalCss'
callAnswerType={modalState.callType} callAnswerType={modalState.callType}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment