import React, { forwardRef } from 'react';
import classNames from 'classnames';
import { faChevronDown } from '@fortawesome/free-solid-svg-icons/faChevronDown';
import { Button } from '../button';
import { useDropdownTrigger } from '../dropdown-menu/use-dropdown-trigger';
import { jsx as _jsx } from "react/jsx-runtime";
/**
  @midnight-gray-supported
  @alpine-light-supported
 */
const DropdownButtonTrigger = /*#__PURE__*/forwardRef(({
  onClick,
  isOpen,
  isDisabled,
  testId,
  accentType,
  buttonProps = {},
  children,
  onKeyboardClick
}, ref) => {
  const {
    onMouseEnter,
    onMouseLeave,
    onMouseClick,
    onKeyDown
  } = useDropdownTrigger({
    onMouseEnter: buttonProps.onMouseEnter,
    onMouseLeave: buttonProps.onMouseLeave,
    onClick,
    triggerOnClickHandler: (_, isKeyboard) => {
      if (isKeyboard) {
        onKeyboardClick?.();
      }
    },
    isOpen
  });
  return /*#__PURE__*/_jsx(Button, {
    ref: ref,
    testId: testId,
    id: testId,
    onMouseEnter: onMouseEnter,
    onMouseLeave: onMouseLeave,
    onClick: onMouseClick,
    onKeyDown: onKeyDown,
    isDisabled: isDisabled,
    rightIcon: faChevronDown,
    accentType: accentType,
    ...buttonProps,
    className: classNames(buttonProps.className, 'dropdown-button-trigger', isOpen && 'expanded'),
    children: children
  });
});
DropdownButtonTrigger.displayName = 'DropdownButtonTrigger';
export default DropdownButtonTrigger;