import { useEffect, useState } from 'react';
import { MuiTelInput } from 'mui-tel-input';
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
interface PhoneProps extends PConnFieldProps {
// If any, enter additional props that only exist on Phone here
}
export default function Phone(props: PhoneProps) {
// Get emitted components from map (so we can get any override that may exist)
const FieldValueList = getComponentFromMap('FieldValueList');
const {
getPConnect,
label,
required,
disabled,
value = '',
validatemessage,
status,
onChange,
readOnly,
testId,
helperText,
displayMode,
hideLabel,
placeholder
} = props;
const pConn = getPConnect();
const actions = pConn.getActionsApi();
const propName = (pConn.getStateProps() as any).value;
const [inputValue, setInputValue] = useState(value);
useEffect(() => setInputValue(value), [value]);
const helperTextToDisplay = validatemessage || helperText;
let testProp = {};
testProp = {
'data-test-id': testId
};
if (displayMode === 'DISPLAY_ONLY') {
return