import { jsx, jsxs } from "react/jsx-runtime";
import { useRef, useState } from "react";
import { Select } from "antd";
function SelectWithTitle(param) {
    let { title, defaultValue, onChange, options, fieldNames } = param;
    const [open, setOpen] = useState(false);
    const timerRef = useRef(null);
    return /*#__PURE__*/ jsxs("div", {
        style: {
            alignItems: 'center',
            display: 'flex',
            justifyContent: 'space-between'
        },
        onClick: (e)=>{
            e.stopPropagation();
            setOpen((v)=>!v);
        },
        onMouseLeave: ()=>{
            timerRef.current = setTimeout(()=>{
                setOpen(false);
            }, 200);
        },
        children: [
            title,
            /*#__PURE__*/ jsx(Select, {
                open: open,
                popupMatchSelectWidth: false,
                variant: "borderless",
                defaultValue: defaultValue,
                onChange: onChange,
                fieldNames: fieldNames,
                options: options,
                style: {
                    textAlign: 'right',
                    minWidth: 100
                },
                onMouseEnter: ()=>{
                    clearTimeout(timerRef.current);
                }
            })
        ]
    });
}
export { SelectWithTitle };
