import type { CSSResultGroup } from 'lit'; import DSAIcon from '../icon/icon'; import DSASpinner from '../spinner/spinner'; import { ShoelaceElement } from '../../internal/shoelace-element'; import type { ShoelaceFormControl } from '../../internal/shoelace-element'; /** * @summary Buttons represent actions that are available to the user. * @documentation https://dsa.service-public-autonomie.fr/latest/librairie-webcomponents/actions/bouton-button/web-NwtTT6wj * * @dependency dsa-icon * @dependency dsa-spinner * * @event dsa-blur - Emitted when the button loses focus. * @event dsa-focus - Emitted when the button gains focus. * @event dsa-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * @event dsa-change - Emitted when a toggle button changes its pressed state. * * @slot - The button's label. * @slot prefix - A presentational prefix icon or similar element. * @slot suffix - A presentational suffix icon or similar element. */ export default class DSAButton extends ShoelaceElement implements ShoelaceFormControl { static styles: CSSResultGroup; static dependencies: { 'dsa-icon': typeof DSAIcon; 'dsa-spinner': typeof DSASpinner; }; private readonly formControlController; private readonly localize; button: HTMLButtonElement | HTMLLinkElement; private hasFocus; invalid: boolean; /** (deprecated) The use of this attribute will lead to a duplicated reading by screen readers. You can use the accessible-name attribute instead. */ title: string; /** The button's theme variant. */ variant: 'primary' | 'secondary' | 'tertiary' | 'tertiary-with-outline' | 'neutral' | 'danger' | 'navigation'; /** The button's size. */ size: 'small' | 'medium' | 'large'; /** Draws the button with a caret. Used to indicate that the button triggers a dropdown menu or similar behavior. This property should only be used within a `dsa-dropdown` */ caret: boolean; /** Disables the button. */ disabled: boolean; /** Draws the button in a loading state. */ loading: boolean; /** Draws the button with it's floating menu style. When this is false the default style is on base. */ floating: boolean; /** Draws the button with it's contrasted menu style. When this is false the default style is on base. */ contrasted: boolean; /** Determines if the button is toggleable (if it can be switched on and off) */ toggle: boolean; /** Determines if the button is pressed (toggled on) or not */ pressed: boolean; /** * The type of button. Note that the default value is `button` instead of `submit`, which is opposite of how native * `