import React from 'react'; import { ComponentProps } from '../utils/types'; /** @public */ type ButtonClickHandler = (event: React.MouseEvent, data: { action?: string; icon?: React.ReactNode; label?: React.ReactNode; value?: any; }) => void; interface ButtonPropsBase { /** Returns a value on click. Use when composing or testing. */ action?: string; /** Changes the style of the button. */ appearance?: 'default' | 'secondary' | 'primary' | 'destructive' | 'destructiveSecondary' | 'standalone' | 'subtle'; /** Removes the right border and border-radius of the button so you can * append other elements to it. */ append?: boolean; children?: React.ReactNode; /** @private An additional className to add to the button. */ classNamePrivate?: string; /** * Prevents user from activating the button and adds disabled styling. * * If set to `dimmed`, the component is able to receive focus. * If set to `disabled`, the component is unable to receive focus (as a result of setting the html `disabled` attribute). * * The default behavior when `disabled={true}` is `dimmed`. */ disabled?: boolean | 'dimmed' | 'disabled'; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * @private * Turns the button red. If you use this prop, apply other error * indicators, such as an error message, to meet accessibility * requirements. * */ error?: boolean; /** Applies the text that displays on the button. */ label?: React.ReactNode; /** Applies an icon to the button. See @splunk/react-icons documentation for * more information. */ icon?: React.ReactNode; /** * Restricts the horizontal size of the button. Set `inline` to `false` to * remove the right margin and stretch the button to the full width of * its container. */ inline?: boolean; /** * Uses interactive styling and adds the chevron-down icon to indicate menu behavior. * * **Accessibility:** This prop should be used with the `Dropdown` component, which manages * the required `aria-controls` and `aria-expanded` attributes. If not using `Dropdown`, * you must manually provide these ARIA attributes. */ isMenu?: boolean; /** * Called when the user activates the button. * */ onClick?: ButtonClickHandler; /** * Open the "to" link in a new context, which is usually a new tab or window based on browser settings. * * An icon and a screen reader message is added to indicate this behavior to users. * The default message is "(Opens new window)"; this can be customized by passing * a string instead of boolean to `openInNewContext`. */ openInNewContext?: boolean | string; /** Removes the left border and border-radius of the button so you can * prepend elements to it. */ prepend?: boolean; /** Identifies the URL for a link. If set, Splunk UI applies an tag * instead of a