import Component from 'flarum/Component'; import icon from 'flarum/helpers/icon'; import listItems from 'flarum/helpers/listItems'; /** * The `Dropdown` component displays a button which, when clicked, shows a * dropdown menu beneath it. * * ### Props * * - `buttonClassName` A class name to apply to the dropdown toggle button. * - `menuClassName` A class name to apply to the dropdown menu. * - `icon` The name of an icon to show in the dropdown toggle button. * - `caretIcon` The name of an icon to show on the right of the button. * - `label` The label of the dropdown toggle button. Defaults to 'Controls'. * - `onhide` * * The children will be displayed as a list inside of the dropdown menu. */ export default class Dropdown extends Component { static initProps(props) { super.initProps(props); props.className = props.className || ''; props.buttonClassName = props.buttonClassName || ''; props.menuClassName = props.menuClassName || ''; props.label = props.label || ''; props.caretIcon = typeof props.caretIcon !== 'undefined' ? props.caretIcon : 'caret-down'; } view() { const items = this.props.children ? listItems(this.props.children) : []; return (