import * as React from "react"; import { FC, useCallback, useMemo, useRef, useState } from "react"; import { Avatar, MenuItem, Select, SelectChangeEvent, Typography, useMediaQuery, useTheme, Box } from "@mui/material"; import arrow_down from "@icons/arrow_down.svg"; import { MinifiedData } from "@/pages/IntegrationsPage/IntegrationsModal/Amo/types"; import { CustomRadioGroup } from "@/components/CustomRadioGroup/CustomRadioGroup"; type CustomSelectProps = { items: MinifiedData[] | []; selectedItemId: string | null; setSelectedItem: (value: string | null) => void; handleScroll: () => void; }; export const CurrentFieldSelect: FC = ({ items, selectedItemId, setSelectedItem, handleScroll }) => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down(600)); const ref = useRef(null); const [opened, setOpened] = useState(false); const toggleOpened = useCallback(() => { setOpened((isOpened) => !isOpened); }, []); const onScroll = useCallback((e: React.UIEvent) => { const scrollHeight = e.currentTarget.scrollHeight; const scrollTop = e.currentTarget.scrollTop; const clientHeight = e.currentTarget.clientHeight; const scrolledToBottom = scrollTop / (scrollHeight - clientHeight) > 0.9; if (scrolledToBottom) { handleScroll(); } }, []); const currentItem = items.find((item) => item.id === selectedItemId) || null return ( {currentItem?.title || "Выберите поле"} check {opened && { }} activeScope={undefined} /> } ); };