From 2581036c53b98d4a4e76c40495e0d7ac31fc8cae Mon Sep 17 00:00:00 2001 From: MrSubhonbek Date: Mon, 19 Jun 2023 09:43:30 +0300 Subject: [PATCH] web component input phone add rtl in country item --- packages/components/input-phone/index.js | 29 ++++++++-- .../input-phone/styled-input-phone.js | 17 ++++++ packages/components/scrollbar/index.js | 58 ++++++++++++------- 3 files changed, 76 insertions(+), 28 deletions(-) diff --git a/packages/components/input-phone/index.js b/packages/components/input-phone/index.js index f75a5bb2ca..6d19fcc1b2 100644 --- a/packages/components/input-phone/index.js +++ b/packages/components/input-phone/index.js @@ -1,9 +1,12 @@ import { useState, useEffect } from "react"; -import { options } from "./options"; +import { useTheme } from "styled-components"; import { FixedSizeList as List } from "react-window"; -import { StyledBox } from "./styled-input-phone"; -import InvalidSvgUrl from "PUBLIC_DIR/images/phoneFlags/invalid.svg?url"; import PropTypes from "prop-types"; + +import { options } from "./options"; +import { StyledBox } from "./styled-input-phone"; + +import InvalidSvgUrl from "PUBLIC_DIR/images/phoneFlags/invalid.svg?url"; import CustomScrollbarsVirtualList from "../scrollbar/custom-scrollbars-virtual-list"; import Box from "@docspace/components/box"; import ComboBox from "@docspace/components/combobox"; @@ -31,6 +34,7 @@ const InputPhone = ({ const [filteredOptions, setFilteredOptions] = useState([]); const [isOpen, setIsOpen] = useState(false); const [isValid, setIsValid] = useState(true); + const theme = useTheme(); const onInputChange = (e) => { const str = e.target.value.replace(/\D/g, ""); @@ -104,6 +108,13 @@ const InputPhone = ({ const Row = ({ data, index, style }) => { const country = data[index]; const prefix = "+"; + const RtlRowComponent = () => ( + <> + {country.dialCode} + {prefix} + {country.name} + + ); return ( - {country.name} - {prefix} - {country.dialCode} + {theme.interfaceDirection === "rtl" ? ( + + ) : ( + <> + {country.name} + {prefix} + {country.dialCode} + + )} ); }; diff --git a/packages/components/input-phone/styled-input-phone.js b/packages/components/input-phone/styled-input-phone.js index 7e3823d255..cdbea04344 100644 --- a/packages/components/input-phone/styled-input-phone.js +++ b/packages/components/input-phone/styled-input-phone.js @@ -136,11 +136,23 @@ export const StyledBox = styled(Box)` .country-name { margin-left: 10px; + ${(props) => + props.theme.interfaceDirection === "rtl" && + css` + margin-left: 0px; + margin-right: 10px; + `} color: ${(props) => props.theme.inputPhone.color}; } .country-prefix { margin-left: 5px; + ${(props) => + props.theme.interfaceDirection === "rtl" && + css` + margin-left: 0px; + margin-right: 5px; + `} color: ${(props) => props.theme.inputPhone.dialCodeColor}; } @@ -151,6 +163,11 @@ export const StyledBox = styled(Box)` .country-item { display: flex; align-items: center; + ${(props) => + props.theme.interfaceDirection === "rtl" && + css` + flex-direction: row-reverse; + `} max-width: 100%; padding: 0; height: 36px; diff --git a/packages/components/scrollbar/index.js b/packages/components/scrollbar/index.js index 52a32bc044..e3de64864b 100644 --- a/packages/components/scrollbar/index.js +++ b/packages/components/scrollbar/index.js @@ -1,8 +1,11 @@ import React from "react"; import PropTypes from "prop-types"; +import { useTheme } from "styled-components"; + import { isMobile } from "@docspace/components/utils/device"; import StyledScrollbar from "./styled-scrollbar"; import { classNames } from "../utils/classNames"; + const Scrollbar = React.forwardRef((props, ref) => { const scrollbarType = { smallWhite: { @@ -66,31 +69,42 @@ const Scrollbar = React.forwardRef((props, ref) => { const thumbV = stype ? stype.thumbV : {}; const thumbH = stype ? stype.thumbH : {}; const view = stype ? stype.view : {}; + const theme = useTheme(); - const renderNavThumbVertical = ({ style, ...props }) => ( -
- ); + const renderNavThumbVertical = ({ style, ...props }) => { + return ( +
+ ); + }; - const renderNavThumbHorizontal = ({ style, ...props }) => ( -
- ); + const renderNavThumbHorizontal = ({ style, ...props }) => { + return ( +
+ ); + }; - const renderView = ({ style, ...rest }) => ( -
- ); + const renderView = ({ style, ...rest }) => { + return ( +
+ ); + }; return (