Web: Components: Adapt TextInput component to RTL interface

This commit is contained in:
Aleksandr Lushkin 2023-06-07 17:33:06 +02:00
parent b33e547924
commit 706c166255
2 changed files with 31 additions and 1 deletions

View File

@ -50,6 +50,30 @@ const commonInputStyle = css`
cursor: ${(props) =>
props.isReadOnly || props.isDisabled ? "default" : "text"};
${(props) =>
props.theme.interfaceDirection === "rtl" &&
css`
// If current interface direction is rtl, set cursor in the right side of the input
:placeholder-shown {
direction: rtl;
}
::placeholder {
text-align: right;
}
&[type="email"]:placeholder-shown,
&[type="tel"]:placeholder-shown,
&[type="number"]:placeholder-shown,
&[type="url"]:placeholder-shown {
direction: ltr;
}
&[type="password"] {
direction: rtl;
}
`}
`;
export default commonInputStyle;

View File

@ -17,6 +17,7 @@ const Input = ({
forwardedRef,
className,
theme,
dir = "auto",
...props
}) => {
const rest = {};
@ -33,7 +34,12 @@ const Input = ({
{...props}
/>
) : (
<input className={`${className} not-selectable`} {...props} {...rest} />
<input
className={`${className} not-selectable`}
dir={dir}
{...props}
{...rest}
/>
);
};
export default Input;