/* eslint-disable @typescript-eslint/no-explicit-any */ import { useState, useRef } from "react"; import AdvancedSearchView from "./AdvancedSearchView"; import FilterPopup from "./FilterPopup"; import { FilterTarget } from "../../data/advancedSearch"; import { useFilterData } from "./helper/useFilterData"; import { useClickOutside } from "../../../../utils/useClickOutside"; type AdvancedSearchProps = { visible: boolean; disabled: boolean; enableCustomView?: boolean; filterableFields: FilterTarget[]; uiElementGroupData: Record; config: { uiElementGroupId: string }; onModelUpdate: ( callBack: ((args: any) => void) | null, fieldName: string, value: any, ) => void; loadTemplateSupportiveData?: ( callBack: (args: any) => void, supportiveKeys: any, ) => Promise; }; const AdvancedSearch: React.FC = (props) => { const { loadSupportiveData, cache } = useFilterData({ loadTemplateSupportiveData: props.loadTemplateSupportiveData, }); const [togglePopup, setTogglePopup] = useState(false); const popupRef = useRef(null); const handlePopupShow = () => { setTogglePopup(!togglePopup); }; useClickOutside( popupRef, togglePopup, () => setTogglePopup(false), (target) => Boolean(target.closest(`.tmpl-prvent-outside-click-close`)), ); return props.visible ? (
0) } /> {togglePopup && !props.disabled && (
e.stopPropagation()} >
)}
) : ( <> ); }; export default AdvancedSearch;