import { useEffect, useState } from 'react';
import { TextField } from '@mui/material';
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
import StyledPegaDxilMyUrlWrapper from './styles';
interface PegaDxilMyUrlProps extends PConnFieldProps {
// If any, enter additional props that only exist on this componentName
}
// Duplicated runtime code from React SDK
// props passed in combination of props from property panel (config.json) and run time props from Constellation
export default function PegaDxilMyUrl(props: PegaDxilMyUrlProps) {
// Get emitted components from map (so we can get any override that may exist)
const FieldValueList = getComponentFromMap('FieldValueList');
const TextInput = getComponentFromMap('TextInput');
const {
getPConnect,
label,
required,
disabled,
value = '',
validatemessage,
status,
readOnly,
testId,
helperText,
displayMode,
hideLabel,
placeholder
} = props;
const helperTextToDisplay = validatemessage || helperText;
const [inputValue, setInputValue] = useState('');
const pConn = getPConnect();
const actions = pConn.getActionsApi();
const propName = (pConn.getStateProps() as any).value;
useEffect(() => {
setInputValue(value);
}, [value]);
if (displayMode === 'DISPLAY_ONLY') {
return ;
}
if (displayMode === 'STACKED_LARGE_VAL') {
return ;
}
if (readOnly) {
return ;
}
let testProp = {};
testProp = {
'data-test-id': testId
};
const handleChange = event => {
setInputValue(event?.target?.value);
};
function handleBlur() {
handleEvent(actions, 'changeNblur', propName, inputValue);
}
return (
);
}