mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { HTMLAttributes, PropsWithChildren, forwardRef, memo, useImperativeHandle, useRef } from 'react';
|
|
|
|
import { cx } from '../../../../common/utils/styleUtils';
|
|
|
|
import style from './TextLikeInput.module.scss';
|
|
|
|
interface TextLikeInputProps extends HTMLAttributes<HTMLSpanElement> {
|
|
offset?: 'over' | 'under' | 'muted' | null;
|
|
muted?: boolean;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
const TextLikeInput = forwardRef(
|
|
(
|
|
{ offset, muted, disabled, children, className, ...elementProps }: PropsWithChildren<TextLikeInputProps>,
|
|
textRef,
|
|
) => {
|
|
const ref = useRef<HTMLDivElement | null>(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 (
|
|
<div className={classes} tabIndex={disabled ? -1 : 0} {...elementProps} ref={ref}>
|
|
{children}
|
|
</div>
|
|
);
|
|
},
|
|
);
|
|
|
|
TextLikeInput.displayName = 'TextLikeInput';
|
|
|
|
export default memo(TextLikeInput);
|