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';
import useStatus from '@pega/react-sdk-components/lib/hooks/useStatus';
import { getFieldSx } from '@pega/react-sdk-components/lib/components/helpers/field-utils';
interface PhoneProps extends PConnFieldProps {
// If any, enter additional props that only exist on Phone here
showFieldMessage?: boolean;
messageConfig?: {
content?: string;
visibility?: boolean;
};
variant?: string;
}
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,
onChange,
readOnly,
testId,
helperText,
displayMode,
hideLabel,
placeholder,
showFieldMessage,
messageConfig = {}
} = 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 eligibleForFieldWarning = showFieldMessage && messageConfig.visibility && !readOnly;
const helperTextToDisplay = validatemessage || (eligibleForFieldWarning ? messageConfig.content : helperText);
const status = useStatus({
showFieldMessage,
messageVisibility: messageConfig.visibility,
validatemessage,
readOnly
});
let testProp = {};
testProp = {
'data-test-id': testId
};
if (displayMode === 'DISPLAY_ONLY') {
return