import {JSX, mergeProps, splitProps} from "solid-js"; import {ButtonType} from "solid-bootstrap-core"; import Button from "./Button"; import ButtonGroup from "./ButtonGroup"; import Dropdown, {DropdownProps} from "./Dropdown"; import {PropsFromToggle} from "./DropdownToggle"; import {BsPrefixProps} from "./helpers"; export interface SplitButtonProps extends Omit, PropsFromToggle, BsPrefixProps { menuRole?: DropdownProps["role"]; renderMenuOnMount?: boolean; rootCloseEvent?: "click" | "mousedown"; target?: string; title: JSX.Element; toggleLabel?: string; type?: ButtonType; } const defaultProps: Partial = { toggleLabel: "Toggle dropdown", type: "button", }; /** * A convenience component for simple or general use split button dropdowns. Renders a * `ButtonGroup` containing a `Button` and a `Button` toggle for the `Dropdown`. All `children` * are passed directly to the default `Dropdown.Menu`. This component accepts all of [`Dropdown`'s * props](#dropdown-props). * * _All unknown props are passed through to the `Dropdown` component._ * The Button `variant`, `size` and `bsPrefix` props are passed to the button and toggle, * and menu-related props are passed to the `Dropdown.Menu` */ const SplitButton = (p: SplitButtonProps) => { const [local, props] = splitProps(mergeProps(defaultProps, p), [ "id", "bsPrefix", "size", "variant", "title", "type", "toggleLabel", "children", "onClick", "href", "target", "menuRole", "renderMenuOnMount", "rootCloseEvent", ]); return ( {local.toggleLabel} {local.children} ); }; export default SplitButton;