// Copyright 1999-2025. WebPros International GmbH. All rights reserved.

import Dropdown from '../Dropdown';
import Menu, { MenuItem } from '../Menu';
import { jsx as _jsx } from "react/jsx-runtime";
const DropdownControl = _ref => {
  let {
    buttons,
    selected,
    onClick
  } = _ref;
  const {
    title = ''
  } = buttons.find(button => button.value === selected) || {};
  const menu = /*#__PURE__*/_jsx(Menu, {
    children: buttons.map(_ref2 => {
      let {
        title,
        value,
        ...buttonProps
      } = _ref2;
      const handleClick = () => {
        onClick(value);
      };
      return /*#__PURE__*/_jsx(MenuItem, {
        ...buttonProps,
        onClick: handleClick,
        children: title
      }, `${value}`);
    })
  });
  return /*#__PURE__*/_jsx(Dropdown, {
    menu: menu,
    children: title
  });
};
export default DropdownControl;