primeng
Version:
PrimeNG is an open source UI library for Angular featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeB
479 lines (474 loc) • 16.7 kB
TypeScript
import * as i0 from '@angular/core';
import { TemplateRef, AfterViewInit, OnDestroy, AfterContentInit, EventEmitter, QueryList } from '@angular/core';
import * as i2 from 'primeng/api';
import { PrimeTemplate } from 'primeng/api';
import { BaseComponent } from 'primeng/basecomponent';
import { Fluid } from 'primeng/fluid';
import * as i1 from '@angular/common';
import { NgClass } from '@angular/common';
import * as _primeuix_styled from '@primeuix/styled';
import { BaseStyle } from 'primeng/base';
/**
* Defines valid templates in Button.
* @group Templates
*/
interface ButtonTemplates {
/**
* Custom template of content.
*/
content(): TemplateRef<any>;
/**
* Custom template of icon.
*/
icon(context: {
/**
* Icon class.
*/
class: NgClass;
}): TemplateRef<NgClass>;
/**
* Custom template of loadingicon.
*/
loadingicon(context: {
/**
* Icon class.
*/
class: NgClass;
}): TemplateRef<NgClass>;
}
type ButtonIconPosition$1 = 'left' | 'right' | 'top' | 'bottom';
interface ButtonProps {
type?: string;
iconPos?: ButtonIconPosition$1;
icon?: string | undefined;
badge?: string | undefined;
label?: string | undefined;
disabled?: boolean | undefined;
loading?: boolean;
loadingIcon?: string | undefined;
raised?: boolean;
rounded?: boolean;
text?: boolean;
plain?: boolean;
severity?: ButtonSeverity;
outlined?: boolean;
link?: boolean;
tabindex?: number | undefined;
size?: 'small' | 'large' | undefined;
style?: {
[klass: string]: any;
} | null | undefined;
styleClass?: string | undefined;
badgeClass?: string | undefined;
badgeSeverity?: 'success' | 'info' | 'warning' | 'danger' | 'help' | 'primary' | 'secondary' | 'contrast' | null | undefined;
ariaLabel?: string | undefined;
autofocus?: boolean | undefined;
variant?: string | undefined;
}
type ButtonSeverity = 'success' | 'info' | 'warn' | 'danger' | 'help' | 'primary' | 'secondary' | 'contrast' | null | undefined;
/**
*
* Button is an extension to standard button element with icons and theming.
*
* [Live Demo](https://www.primeng.org/button/)
*
* @module buttonstyle
*
*/
declare enum ButtonClasses {
/**
* Class name of the root element
*/
root = "p-button",
/**
* Class name of the loading icon element
*/
loadingIcon = "p-button-loading-icon",
/**
* Class name of the icon element
*/
icon = "p-button-icon",
/**
* Class name of the label element
*/
label = "p-button-label"
}
declare class ButtonStyle extends BaseStyle {
name: string;
theme: _primeuix_styled.StyleType;
classes: {
root: ({ instance }: {
instance: any;
}) => (string | {
[x: string]: any;
'p-button-icon-only': boolean;
'p-button-vertical': any;
'p-button-loading': any;
'p-button-link': any;
'p-button-raised': any;
'p-button-rounded': any;
'p-button-text': any;
'p-button-outlined': any;
'p-button-sm': boolean;
'p-button-lg': boolean;
'p-button-plain': any;
'p-button-fluid': any;
})[];
loadingIcon: string;
icon: ({ instance }: {
instance: any;
}) => any[];
spinnerIcon: ({ instance }: {
instance: any;
}) => string;
label: string;
};
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonStyle, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ButtonStyle>;
}
interface ButtonStyle extends BaseStyle {
}
type ButtonIconPosition = 'left' | 'right' | 'top' | 'bottom';
declare class ButtonLabel extends BaseComponent {
_componentStyle: ButtonStyle;
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonLabel, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ButtonLabel, "[pButtonLabel]", never, {}, {}, never, never, true, never>;
}
declare class ButtonIcon extends BaseComponent {
_componentStyle: ButtonStyle;
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonIcon, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ButtonIcon, "[pButtonIcon]", never, {}, {}, never, never, true, never>;
}
/**
* Button directive is an extension to button component.
* @group Components
*/
declare class ButtonDirective extends BaseComponent implements AfterViewInit, OnDestroy {
/**
* Position of the icon.
* @deprecated utilize pButtonIcon and pButtonLabel directives.
* @group Props
*/
iconPos: ButtonIconPosition;
/**
* Uses to pass attributes to the loading icon's DOM element.
* @deprecated utilize pButonIcon instead.
* @group Props
*/
loadingIcon: string | undefined;
set label(val: string);
set icon(val: string);
/**
* Whether the button is in loading state.
* @group Props
*/
get loading(): boolean;
set loading(val: boolean);
_buttonProps: ButtonProps;
private iconSignal;
private labelSignal;
isIconOnly: i0.Signal<boolean>;
set buttonProps(val: ButtonProps);
private _severity;
/**
* Defines the style of the button.
* @group Props
*/
get severity(): ButtonSeverity;
set severity(value: ButtonSeverity);
/**
* Add a shadow to indicate elevation.
* @group Props
*/
raised: boolean;
/**
* Add a circular border radius to the button.
* @group Props
*/
rounded: boolean;
/**
* Add a textual class to the button without a background initially.
* @group Props
*/
text: boolean;
/**
* Add a border class without a background initially.
* @group Props
*/
outlined: boolean;
/**
* Defines the size of the button.
* @group Props
*/
size: 'small' | 'large' | undefined | null;
/**
* Add a plain textual class to the button without a background initially.
* @group Props
*/
plain: boolean;
/**
* Spans 100% width of the container when enabled.
* @defaultValue undefined
* @group Props
*/
fluid: i0.InputSignalWithTransform<boolean, unknown>;
_label: string | undefined;
_icon: string | undefined;
_loading: boolean;
initialized: boolean | undefined;
private get htmlElement();
private _internalClasses;
pcFluid: Fluid;
isTextButton: i0.Signal<boolean>;
/**
* Text of the button.
* @deprecated use pButtonLabel directive instead.
* @group Props
*/
get label(): string | undefined;
/**
* Name of the icon.
* @deprecated use pButtonIcon directive instead
* @group Props
*/
get icon(): string;
/**
* Used to pass all properties of the ButtonProps to the Button component.
* @deprecated assign props directly to the button element.
* @group Props
*/
get buttonProps(): ButtonProps;
spinnerIcon: string;
_componentStyle: ButtonStyle;
ngAfterViewInit(): void;
getStyleClass(): string[];
get hasFluid(): boolean;
setStyleClass(): void;
removeExistingSeverityClass(): void;
createLabel(): void;
createIcon(): void;
updateLabel(): void;
updateIcon(): void;
getIconClass(): string;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ButtonDirective, "[pButton]", never, { "iconPos": { "alias": "iconPos"; "required": false; }; "loadingIcon": { "alias": "loadingIcon"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "severity": { "alias": "severity"; "required": false; }; "raised": { "alias": "raised"; "required": false; }; "rounded": { "alias": "rounded"; "required": false; }; "text": { "alias": "text"; "required": false; }; "outlined": { "alias": "outlined"; "required": false; }; "size": { "alias": "size"; "required": false; }; "plain": { "alias": "plain"; "required": false; }; "fluid": { "alias": "fluid"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "buttonProps": { "alias": "buttonProps"; "required": false; }; }, {}, ["iconSignal", "labelSignal"], never, true, never>;
static ngAcceptInputType_raised: unknown;
static ngAcceptInputType_rounded: unknown;
static ngAcceptInputType_text: unknown;
static ngAcceptInputType_outlined: unknown;
static ngAcceptInputType_plain: unknown;
}
/**
* Button is an extension to standard button element with icons and theming.
* @group Components
*/
declare class Button extends BaseComponent implements AfterContentInit {
/**
* Type of the button.
* @group Props
*/
type: string;
/**
* Position of the icon.
* @group Props
*/
iconPos: ButtonIconPosition;
/**
* Name of the icon.
* @group Props
*/
icon: string | undefined;
/**
* Value of the badge.
* @group Props
*/
badge: string | undefined;
/**
* Uses to pass attributes to the label's DOM element.
* @group Props
*/
label: string | undefined;
/**
* When present, it specifies that the component should be disabled.
* @group Props
*/
disabled: boolean | undefined;
/**
* Whether the button is in loading state.
* @group Props
*/
loading: boolean;
/**
* Icon to display in loading state.
* @group Props
*/
loadingIcon: string | undefined;
/**
* Add a shadow to indicate elevation.
* @group Props
*/
raised: boolean;
/**
* Add a circular border radius to the button.
* @group Props
*/
rounded: boolean;
/**
* Add a textual class to the button without a background initially.
* @group Props
*/
text: boolean;
/**
* Add a plain textual class to the button without a background initially.
* @group Props
*/
plain: boolean;
/**
* Defines the style of the button.
* @group Props
*/
severity: ButtonSeverity;
/**
* Add a border class without a background initially.
* @group Props
*/
outlined: boolean;
/**
* Add a link style to the button.
* @group Props
*/
link: boolean;
/**
* Add a tabindex to the button.
* @group Props
*/
tabindex: number | undefined;
/**
* Defines the size of the button.
* @group Props
*/
size: 'small' | 'large' | undefined;
/**
* Specifies the variant of the component.
* @group Props
*/
variant: 'outlined' | 'text' | undefined;
/**
* Inline style of the element.
* @group Props
*/
style: {
[klass: string]: any;
} | null | undefined;
/**
* Class of the element.
* @group Props
*/
styleClass: string | undefined;
/**
* Style class of the badge.
* @group Props
* @deprecated use badgeSeverity instead.
*/
badgeClass: string | undefined;
/**
* Severity type of the badge.
* @group Props
* @defaultValue secondary
*/
badgeSeverity: 'success' | 'info' | 'warn' | 'danger' | 'help' | 'primary' | 'secondary' | 'contrast' | null | undefined;
/**
* Used to define a string that autocomplete attribute the current element.
* @group Props
*/
ariaLabel: string | undefined;
/**
* Button props as an object.
* @group Props
*/
buttonProps: any | ButtonProps;
/**
* When present, it specifies that the component should automatically get focus on load.
* @group Props
*/
autofocus: boolean | undefined;
/**
* Spans 100% width of the container when enabled.
* @defaultValue undefined
* @group Props
*/
fluid: i0.InputSignalWithTransform<boolean, unknown>;
/**
* Callback to execute when button is clicked.
* This event is intended to be used with the <p-button> component. Using a regular <button> element, use (click).
* @param {MouseEvent} event - Mouse event.
* @group Emits
*/
onClick: EventEmitter<MouseEvent>;
/**
* Callback to execute when button is focused.
* This event is intended to be used with the <p-button> component. Using a regular <button> element, use (focus).
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onFocus: EventEmitter<FocusEvent>;
/**
* Callback to execute when button loses focus.
* This event is intended to be used with the <p-button> component. Using a regular <button> element, use (blur).
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onBlur: EventEmitter<FocusEvent>;
/**
* Template of the content.
* @group Templates
**/
contentTemplate: TemplateRef<any> | undefined;
/**
* Template of the loading.
* @group Templates
**/
loadingIconTemplate: TemplateRef<any> | undefined;
/**
* Template of the icon.
* @group Templates
**/
iconTemplate: TemplateRef<any> | undefined;
templates: QueryList<PrimeTemplate> | undefined;
pcFluid: Fluid;
get hasFluid(): boolean;
_componentStyle: ButtonStyle;
_contentTemplate: TemplateRef<any> | undefined;
_iconTemplate: TemplateRef<any> | undefined;
_loadingIconTemplate: TemplateRef<any> | undefined;
ngAfterContentInit(): void;
spinnerIconClass(): string;
iconClass(): {
[x: string]: string | boolean;
'p-button-icon': boolean;
'p-button-icon-left': string;
'p-button-icon-right': string;
'p-button-icon-top': string;
'p-button-icon-bottom': string;
};
static ɵfac: i0.ɵɵFactoryDeclaration<Button, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<Button, "p-button", never, { "type": { "alias": "type"; "required": false; }; "iconPos": { "alias": "iconPos"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "badge": { "alias": "badge"; "required": false; }; "label": { "alias": "label"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "loadingIcon": { "alias": "loadingIcon"; "required": false; }; "raised": { "alias": "raised"; "required": false; }; "rounded": { "alias": "rounded"; "required": false; }; "text": { "alias": "text"; "required": false; }; "plain": { "alias": "plain"; "required": false; }; "severity": { "alias": "severity"; "required": false; }; "outlined": { "alias": "outlined"; "required": false; }; "link": { "alias": "link"; "required": false; }; "tabindex": { "alias": "tabindex"; "required": false; }; "size": { "alias": "size"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "style": { "alias": "style"; "required": false; }; "styleClass": { "alias": "styleClass"; "required": false; }; "badgeClass": { "alias": "badgeClass"; "required": false; }; "badgeSeverity": { "alias": "badgeSeverity"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "buttonProps": { "alias": "buttonProps"; "required": false; }; "autofocus": { "alias": "autofocus"; "required": false; }; "fluid": { "alias": "fluid"; "required": false; "isSignal": true; }; }, { "onClick": "onClick"; "onFocus": "onFocus"; "onBlur": "onBlur"; }, ["contentTemplate", "loadingIconTemplate", "iconTemplate", "templates"], ["*"], true, never>;
static ngAcceptInputType_disabled: unknown;
static ngAcceptInputType_loading: unknown;
static ngAcceptInputType_raised: unknown;
static ngAcceptInputType_rounded: unknown;
static ngAcceptInputType_text: unknown;
static ngAcceptInputType_plain: unknown;
static ngAcceptInputType_outlined: unknown;
static ngAcceptInputType_link: unknown;
static ngAcceptInputType_tabindex: unknown;
static ngAcceptInputType_autofocus: unknown;
}
declare class ButtonModule {
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<ButtonModule, never, [typeof i1.CommonModule, typeof ButtonDirective, typeof Button, typeof i2.SharedModule, typeof ButtonLabel, typeof ButtonIcon], [typeof ButtonDirective, typeof Button, typeof ButtonLabel, typeof ButtonIcon, typeof i2.SharedModule]>;
static ɵinj: i0.ɵɵInjectorDeclaration<ButtonModule>;
}
export { Button, ButtonClasses, ButtonDirective, ButtonIcon, ButtonLabel, ButtonModule, ButtonStyle };
export type { ButtonProps, ButtonSeverity, ButtonTemplates };