import { forwardRef, HTMLAttributes, memo, PropsWithChildren, useImperativeHandle, useRef } from 'react'; import { cx } from '../../../../common/utils/styleUtils'; import style from './TextLikeInput.module.scss'; interface TextLikeInputProps extends HTMLAttributes { offset?: 'over' | 'under' | 'muted' | null; muted?: boolean; disabled?: boolean; } const TextLikeInput = forwardRef( ( { offset, muted, disabled, children, className, ...elementProps }: PropsWithChildren, textRef, ) => { const ref = useRef(null); const classes = cx([ style.textInput, offset && style[offset], muted && style.muted, disabled && style.disabled, className, ]); useImperativeHandle(textRef, () => { return { focusParentElement() { ref.current?.parentElement?.focus(); }, }; }); return (
{children}
); }, ); TextLikeInput.displayName = 'TextLikeInput'; export default memo(TextLikeInput);