) => {
onChange_?.(e);
onValueChange?.(e.target.value, prevValueRef.current);
prevValueRef.current = e.target.value;
});
const prefix = useId();
const rawTextId = id ?? `${prefix}-raw-text-id`;
const inputId = id ?? `${prefix}-input-id`;
const labelForId = readOnly ? rawTextId : inputId;
const errorId = `${prefix}-error-id`;
const { isFieldSetColumn } = useContext(FieldSetColumnContext);
const inputClassNames = classnames(
className,
bare ? 'slds-input_bare' : 'slds-input'
);
const inputElem = readOnly ? (
{value}
) : (
);
let contentElem = inputElem;
if (iconLeft || iconRight || addonLeft || addonRight) {
const wrapperClassName = classnames(
'slds-form-element__control',
{ 'slds-input-has-icon': iconLeft || iconRight },
{ 'slds-input-has-icon_left-right': iconLeft && iconRight },
{ 'slds-input-has-icon_left': iconLeft },
{ 'slds-input-has-icon_right': iconRight },
{ 'slds-input-has-fixed-addon': addonLeft || addonRight }
);
contentElem = (
{addonLeft ? : undefined}
{iconLeft ? : undefined}
{inputElem}
{iconRight ? : undefined}
{addonRight ? : undefined}
);
}
if (isFieldSetColumn || label || required || error || cols) {
const formElemProps = {
controlId: labelForId,
label,
required,
error,
errorId,
readOnly,
cols,
tooltip,
tooltipIcon,
elementRef,
};
return {contentElem};
}
return contentElem;
},
{ isFormElement: true }
);