import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2019-2025 GoodData Corporation
import { useIntl } from "react-intl";
import { Dropdown, DropdownButton } from "@gooddata/sdk-ui-kit";
import { DrillMeasureSelectorBody } from "./DrillMeasureSelectorBody.js";
const DROPDOWN_ALIGN_POINTS = [
    {
        align: "bl tl",
        offset: {
            x: 0,
            y: 4,
        },
    },
    {
        align: "tl bl",
        offset: {
            x: 0,
            y: -4,
        },
    },
];
export function DrillMeasureSelector(props) {
    // const refDropdown = useRef(null);
    //
    const onCloseDropdown = () => {
        // refDropdown.current.closeDropdown();
    };
    const intl = useIntl();
    const onSelect = (selected) => {
        props.onSelect(selected);
        onCloseDropdown();
    };
    if (!props.items.length) {
        return null;
    }
    return (_jsx(Dropdown, { className: "gd-drill-measure-selector", closeOnParentScroll: true, closeOnMouseDrag: false, closeOnOutsideClick: true, alignPoints: DROPDOWN_ALIGN_POINTS, renderButton: ({ toggleDropdown }) => (_jsx(DropdownButton, { value: intl.formatMessage({ id: "configurationPanel.drillConfig.addInteraction" }), iconLeft: "icon-add", className: "s-drill-show-measures customizable", onClick: toggleDropdown })), renderBody: () => (_jsx(DrillMeasureSelectorBody, { supportedItems: props.items, onSelect: onSelect, onCloseDropdown: onCloseDropdown })) }));
}
//# sourceMappingURL=DrillMeasureSelector.js.map