@funidata/ngx-fudis
Version:
Funidata Design System.
143 lines (142 loc) • 4.89 kB
TypeScript
import { EventEmitter, ElementRef, OnChanges, OnInit, OnDestroy } from '@angular/core';
import { FudisIcon, FudisIconRotate } from '../../types/icons';
import { PopoverApiDirective } from '../../directives/popover/popover-api.directive';
import { FudisIdService } from '../../services/id/id.service';
import { FudisButtonSize, FudisButtonType, FudisButtonVariant, FudisComponentChanges } from '../../types/miscellaneous';
import { BehaviorSubject } from 'rxjs';
import { DropdownEventService } from '../../services/dropdown/dropdown-event.service';
import * as i0 from "@angular/core";
export declare class ButtonComponent extends PopoverApiDirective implements OnChanges, OnInit, OnDestroy {
private _idService;
private _dropdownEventService;
constructor(_idService: FudisIdService, _dropdownEventService: DropdownEventService);
/**
* Binding host CSS class to component wrapper
*/
private _classes;
/**
* Reference to native button element
*/
buttonEl: ElementRef<HTMLButtonElement>;
/**
* Text content of the button
*/
label: string;
/**
* Button variant options
*/
variant: FudisButtonVariant;
/**
* Button size options
*/
size: FudisButtonSize;
/**
* Button type options
*/
type: FudisButtonType;
/**
* Hide visible label text for icon-only buttons.
*/
labelHidden: boolean;
/**
* Additional aria-label for describing context
*/
ariaLabel: string;
/**
* Disables the button, keeping it focusable
*/
disabled: boolean;
/**
* Icon for button if needed
*/
icon: FudisIcon | undefined;
/**
* Icon rotation option
*/
iconRotate: FudisIconRotate;
/**
* Id for HTML button element. By default generated.
*/
id: string;
/**
* Assign button as menu button with dropdown
*/
asMenuButton: boolean;
/**
* Click handler
*/
handleClick: EventEmitter<Event>;
/**
* Focus handler
*/
handleFocus: EventEmitter<FocusEvent>;
/**
* Blur handler
*/
handleBlur: EventEmitter<FocusEvent>;
/**
* OnDestroy handler emit
*/
handleDestroy: EventEmitter<void>;
/**
* Toggle dropdown menu button
*/
dropdownOpen: BehaviorSubject<boolean>;
/**
* Id of child Dropdown Menu. Passed from child to parent Button.
*/
dropdownMenuId: string;
/**
* Automatically sets icon color based on button variant
*/
protected _iconColor: BehaviorSubject<"primary" | "yellow" | "red" | "gray-dark" | "gray-light" | "primary-dark" | "green" | "white">;
/**
* Button CSS class list
*/
protected _classList: BehaviorSubject<string[]>;
/**
* Aria-label for icon-only buttons
*/
protected _ariaLabel: BehaviorSubject<string>;
/**
* Is button focused or not
*/
private _focused;
ngOnInit(): void;
ngOnChanges(changes: FudisComponentChanges<ButtonComponent>): void;
ngOnDestroy(): void;
/**
* Button click event
*/
buttonClick(event: Event): void;
/**
* Toggling when Button is used as Menu Button
*/
toggleMenu(): void;
/**
* Close dropdown when Button is used as Menu Button
*/
closeMenu(focusToButton?: boolean): void;
/**
* Handle Escape key down for Menu Button
*/
protected _handleMenuButtonKeyDown(event: KeyboardEvent): void;
/**
* Handler for blurring out and closing Menu Button's dropdown
*/
protected _handleButtonBlur(event: FocusEvent): void;
/**
* Handle button focus
*/
protected _handleButtonFocus(event: FocusEvent): void;
/**
* Add aria-label for buttons without visible label
*/
private _getAriaLabel;
/**
* Determine icon color based on button variant. Return CSS classes with size and variant
*/
private _getClasses;
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ButtonComponent, "fudis-button", never, { "label": { "alias": "label"; "required": true; }; "variant": { "alias": "variant"; "required": false; }; "size": { "alias": "size"; "required": false; }; "type": { "alias": "type"; "required": false; }; "labelHidden": { "alias": "labelHidden"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "iconRotate": { "alias": "iconRotate"; "required": false; }; "id": { "alias": "id"; "required": false; }; "asMenuButton": { "alias": "asMenuButton"; "required": false; }; }, { "handleClick": "handleClick"; "handleFocus": "handleFocus"; "handleBlur": "handleBlur"; "handleDestroy": "handleDestroy"; }, never, ["*"], false, never>;
}