igniteui-angular
Version:
Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps
744 lines (738 loc) • 24.2 kB
TypeScript
import * as i3 from 'igniteui-angular/input-group';
import { IgxPrefixDirective, IgxSuffixDirective } from 'igniteui-angular/input-group';
import * as i0 from '@angular/core';
import { OnInit, OnDestroy, ChangeDetectorRef, TemplateRef, EventEmitter, ElementRef, DoCheck, AfterViewInit, QueryList } from '@angular/core';
import { IDragBaseEventArgs, IDropBaseEventArgs, IgxDragDirective, IDragStartEventArgs, IDropDroppedEventArgs } from 'igniteui-angular/directives';
import { IBaseEventArgs, IChipResourceStrings, ɵSize as _Size } from 'igniteui-angular/core';
import { Subject } from 'rxjs';
declare const IgxChipTypeVariant: {
readonly PRIMARY: "primary";
readonly INFO: "info";
readonly SUCCESS: "success";
readonly WARNING: "warning";
readonly DANGER: "danger";
};
type IgxChipTypeVariant = (typeof IgxChipTypeVariant)[keyof typeof IgxChipTypeVariant];
interface IBaseChipEventArgs extends IBaseEventArgs {
originalEvent: IDragBaseEventArgs | IDropBaseEventArgs | KeyboardEvent | MouseEvent | TouchEvent;
owner: IgxChipComponent;
}
interface IChipClickEventArgs extends IBaseChipEventArgs {
cancel: boolean;
}
interface IChipKeyDownEventArgs extends IBaseChipEventArgs {
originalEvent: KeyboardEvent;
cancel: boolean;
}
interface IChipEnterDragAreaEventArgs extends IBaseChipEventArgs {
dragChip: IgxChipComponent;
}
interface IChipSelectEventArgs extends IBaseChipEventArgs {
cancel: boolean;
selected: boolean;
}
/**
* Chip is compact visual component that displays information in an obround.
*
* @igxModule IgxChipsModule
*
* @igxTheme igx-chip-theme
*
* @igxKeywords chip
*
* @igxGroup display
*
* @remarks
* The Ignite UI Chip can be templated, deleted, and selected.
* Multiple chips can be reordered and visually connected to each other.
* Chips reside in a container called chips area which is responsible for managing the interactions between the chips.
*
* @example
* ```html
* <igx-chip class="chipStyle" [id]="901" [draggable]="true" [removable]="true" (remove)="chipRemoved($event)">
* <igx-avatar class="chip-avatar-resized" igxPrefix></igx-avatar>
* </igx-chip>
* ```
*/
declare class IgxChipComponent implements OnInit, OnDestroy {
cdr: ChangeDetectorRef;
private ref;
private renderer;
document: Document;
/**
* Sets/gets the variant of the chip.
*
* @remarks
* Allowed values are `primary`, `info`, `success`, `warning`, `danger`.
* Providing no/nullish value leaves the chip in its default state.
*
* @example
* ```html
* <igx-chip variant="success"></igx-chip>
* ```
*/
variant?: IgxChipTypeVariant | null;
/**
* Sets the value of `id` attribute. If not provided it will be automatically generated.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'"></igx-chip>
* ```
*/
id: string;
/**
* Returns the `role` attribute of the chip.
*
* @example
* ```typescript
* let chipRole = this.chip.role;
* ```
*/
role: string;
/**
* Sets the value of `tabindex` attribute. If not provided it will use the element's tabindex if set.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'" [tabIndex]="1"></igx-chip>
* ```
*/
set tabIndex(value: number);
get tabIndex(): number;
/**
* Stores data related to the chip.
*
* @example
* ```html
* <igx-chip [data]="{ value: 'Country' }"></igx-chip>
* ```
*/
data: any;
/**
* Defines if the `IgxChipComponent` can be dragged in order to change it's position.
* By default it is set to false.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'" [draggable]="true"></igx-chip>
* ```
*/
draggable: boolean;
/**
* Enables/disables the draggable element animation when the element is released.
* By default it's set to true.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'" [draggable]="true" [animateOnRelease]="false"></igx-chip>
* ```
*/
animateOnRelease: boolean;
/**
* Enables/disables the hiding of the base element that has been dragged.
* By default it's set to true.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'" [draggable]="true" [hideBaseOnDrag]="false"></igx-chip>
* ```
*/
hideBaseOnDrag: boolean;
/**
* Defines if the `IgxChipComponent` should render remove button and throw remove events.
* By default it is set to false.
*
* @example
* ```html
* <igx-chip [id]="'igx-chip-1'" [draggable]="true" [removable]="true"></igx-chip>
* ```
*/
removable: boolean;
/**
* Overrides the default icon that the chip applies to the remove button.
*
* @example
* ```html
* <igx-chip [id]="chip.id" [removable]="true" [removeIcon]="iconTemplate"></igx-chip>
* <ng-template #iconTemplate><igx-icon>delete</igx-icon></ng-template>
* ```
*/
removeIcon: TemplateRef<any>;
/**
* Defines if the `IgxChipComponent` can be selected on click or through navigation,
* By default it is set to false.
*
* @example
* ```html
* <igx-chip [id]="chip.id" [draggable]="true" [removable]="true" [selectable]="true"></igx-chip>
* ```
*/
selectable: boolean;
/**
* Overrides the default icon that the chip applies when it is selected.
*
* @example
* ```html
* <igx-chip [id]="chip.id" [selectable]="true" [selectIcon]="iconTemplate"></igx-chip>
* <ng-template #iconTemplate><igx-icon>done_outline</igx-icon></ng-template>
* ```
*/
selectIcon: TemplateRef<any>;
/**
* @hidden
* @internal
*/
class: string;
/**
* Disables the `IgxChipComponent`. When disabled it restricts user interactions
* like focusing on click or tab, selection on click or Space, dragging.
* By default it is set to false.
*
* @example
* ```html
* <igx-chip [id]="chip.id" [disabled]="true"></igx-chip>
* ```
*/
disabled: boolean;
/**
* Sets the `IgxChipComponent` selected state.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" [selected]="true">
* ```
*
* Two-way data binding:
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" [(selected)]="model.isSelected">
* ```
*/
set selected(newValue: boolean);
/**
* Returns if the `IgxChipComponent` is selected.
*
* @example
* ```typescript
* @ViewChild('myChip')
* public chip: IgxChipComponent;
* selectedChip(){
* let selectedChip = this.chip.selected;
* }
* ```
*/
get selected(): boolean;
/**
* @hidden
* @internal
*/
selectedChange: EventEmitter<boolean>;
/**
* Sets the `IgxChipComponent` background color.
* The `color` property supports string, rgb, hex.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [color]="'#ff0000'"></igx-chip>
* ```
*/
set color(newColor: any);
/**
* Returns the background color of the `IgxChipComponent`.
*
* @example
* ```typescript
* @ViewChild('myChip')
* public chip: IgxChipComponent;
* ngAfterViewInit(){
* let chipColor = this.chip.color;
* }
* ```
*/
get color(): any;
/**
* An accessor that sets the resource strings.
* By default it uses EN resources.
*/
set resourceStrings(value: IChipResourceStrings);
/**
* An accessor that returns the resource strings.
*/
get resourceStrings(): IChipResourceStrings;
/**
* Emits an event when the `IgxChipComponent` moving starts.
* Returns the moving `IgxChipComponent`.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (moveStart)="moveStarted($event)">
* ```
*/
moveStart: EventEmitter<IBaseChipEventArgs>;
/**
* Emits an event when the `IgxChipComponent` moving ends.
* Returns the moved `IgxChipComponent`.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (moveEnd)="moveEnded($event)">
* ```
*/
moveEnd: EventEmitter<IBaseChipEventArgs>;
/**
* Emits an event when the `IgxChipComponent` is removed.
* Returns the removed `IgxChipComponent`.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (remove)="remove($event)">
* ```
*/
remove: EventEmitter<IBaseChipEventArgs>;
/**
* Emits an event when the `IgxChipComponent` is clicked.
* Returns the clicked `IgxChipComponent`, whether the event should be canceled.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (click)="chipClick($event)">
* ```
*/
chipClick: EventEmitter<IChipClickEventArgs>;
/**
* Emits event when the `IgxChipComponent` is selected/deselected.
* Returns the selected chip reference, whether the event should be canceled, what is the next selection state and
* when the event is triggered by interaction `originalEvent` is provided, otherwise `originalEvent` is `null`.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (selectedChanging)="chipSelect($event)">
* ```
*/
selectedChanging: EventEmitter<IChipSelectEventArgs>;
/**
* Emits event when the `IgxChipComponent` is selected/deselected and any related animations and transitions also end.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (selectedChanged)="chipSelectEnd($event)">
* ```
*/
selectedChanged: EventEmitter<IBaseChipEventArgs>;
/**
* Emits an event when the `IgxChipComponent` keyboard navigation is being used.
* Returns the focused/selected `IgxChipComponent`, whether the event should be canceled,
* if the `alt`, `shift` or `control` key is pressed and the pressed key name.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (keyDown)="chipKeyDown($event)">
* ```
*/
keyDown: EventEmitter<IChipKeyDownEventArgs>;
/**
* Emits an event when the `IgxChipComponent` has entered the `IgxChipsAreaComponent`.
* Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as well as
* the original drop event arguments.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragEnter)="chipEnter($event)">
* ```
*/
dragEnter: EventEmitter<IChipEnterDragAreaEventArgs>;
/**
* Emits an event when the `IgxChipComponent` has left the `IgxChipsAreaComponent`.
* Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as well as
* the original drop event arguments.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragLeave)="chipLeave($event)">
* ```
*/
dragLeave: EventEmitter<IChipEnterDragAreaEventArgs>;
/**
* Emits an event when the `IgxChipComponent` is over the `IgxChipsAreaComponent`.
* Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as well as
* the original drop event arguments.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragOver)="chipOver($event)">
* ```
*/
dragOver: EventEmitter<IChipEnterDragAreaEventArgs>;
/**
* Emits an event when the `IgxChipComponent` has been dropped in the `IgxChipsAreaComponent`.
* Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as well as
* the original drop event arguments.
*
* @example
* ```html
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragDrop)="chipLeave($event)">
* ```
*/
dragDrop: EventEmitter<IChipEnterDragAreaEventArgs>;
protected defaultClass: string;
protected get isPrimary(): boolean;
protected get isInfo(): boolean;
protected get isSuccess(): boolean;
protected get isWarning(): boolean;
protected get isDanger(): boolean;
/**
* Property that contains a reference to the `IgxDragDirective` the `IgxChipComponent` uses for dragging behavior.
*
* @example
* ```html
* <igx-chip [id]="chip.id" [draggable]="true"></igx-chip>
* ```
* ```typescript
* onMoveStart(event: IBaseChipEventArgs){
* let dragDirective = event.owner.dragDirective;
* }
* ```
*/
dragDirective: IgxDragDirective;
/**
* @hidden
* @internal
*/
chipArea: ElementRef;
/**
* @hidden
* @internal
*/
defaultRemoveIcon: TemplateRef<any>;
/**
* @hidden
* @internal
*/
defaultSelectIcon: TemplateRef<any>;
/**
* @hidden
* @internal
*/
get removeButtonTemplate(): TemplateRef<any>;
/**
* @hidden
* @internal
*/
get selectIconTemplate(): TemplateRef<any>;
/**
* @hidden
* @internal
*/
get ghostStyles(): {
'--ig-size': string;
};
/** @hidden @internal */
get nativeElement(): HTMLElement;
/**
* @hidden
* @internal
*/
hideBaseElement: boolean;
/**
* @hidden
* @internal
*/
destroy$: Subject<void>;
protected get chipSize(): _Size;
protected _tabIndex: any;
protected _selected: boolean;
protected _selectedItemClass: string;
protected _movedWhileRemoving: boolean;
protected computedStyles: any;
private _resourceStrings;
/**
* @hidden
* @internal
*/
keyEvent(event: KeyboardEvent): void;
/**
* @hidden
* @internal
*/
selectClass(condition: boolean): any;
onSelectTransitionDone(event: any): void;
/**
* @hidden
* @internal
*/
onChipKeyDown(event: KeyboardEvent): void;
/**
* @hidden
* @internal
*/
onRemoveBtnKeyDown(event: KeyboardEvent): void;
onRemoveMouseDown(event: PointerEvent | MouseEvent): void;
/**
* @hidden
* @internal
*/
onRemoveClick(event: MouseEvent | TouchEvent): void;
/**
* @hidden
* @internal
*/
onRemoveTouchMove(): void;
/**
* @hidden
* @internal
*/
onRemoveTouchEnd(event: TouchEvent): void;
/**
* @hidden
* @internal
*/
onChipDragStart(event: IDragStartEventArgs): void;
/**
* @hidden
* @internal
*/
onChipDragEnd(): void;
/**
* @hidden
* @internal
*/
onChipMoveEnd(event: IDragBaseEventArgs): void;
/**
* @hidden
* @internal
*/
onChipGhostCreate(): void;
/**
* @hidden
* @internal
*/
onChipGhostDestroy(): void;
/**
* @hidden
* @internal
*/
onChipDragClicked(event: IDragBaseEventArgs): void;
/**
* @hidden
* @internal
*/
onChipDragEnterHandler(event: IDropBaseEventArgs): void;
/**
* @hidden
* @internal
*/
onChipDragLeaveHandler(event: IDropBaseEventArgs): void;
/**
* @hidden
* @internal
*/
onChipDrop(event: IDropDroppedEventArgs): void;
/**
* @hidden
* @internal
*/
onChipOverHandler(event: IDropBaseEventArgs): void;
protected changeSelection(newValue: boolean, srcEvent?: any): void;
ngOnInit(): void;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<IgxChipComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<IgxChipComponent, "igx-chip", never, { "variant": { "alias": "variant"; "required": false; }; "id": { "alias": "id"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "data": { "alias": "data"; "required": false; }; "draggable": { "alias": "draggable"; "required": false; }; "animateOnRelease": { "alias": "animateOnRelease"; "required": false; }; "hideBaseOnDrag": { "alias": "hideBaseOnDrag"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "removeIcon": { "alias": "removeIcon"; "required": false; }; "selectable": { "alias": "selectable"; "required": false; }; "selectIcon": { "alias": "selectIcon"; "required": false; }; "class": { "alias": "class"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "color": { "alias": "color"; "required": false; }; "resourceStrings": { "alias": "resourceStrings"; "required": false; }; }, { "selectedChange": "selectedChange"; "moveStart": "moveStart"; "moveEnd": "moveEnd"; "remove": "remove"; "chipClick": "chipClick"; "selectedChanging": "selectedChanging"; "selectedChanged": "selectedChanged"; "keyDown": "keyDown"; "dragEnter": "dragEnter"; "dragLeave": "dragLeave"; "dragOver": "dragOver"; "dragDrop": "dragDrop"; }, never, ["igx-prefix,[igxPrefix]", "*", "igx-suffix,[igxSuffix]"], true, never>;
static ngAcceptInputType_draggable: unknown;
static ngAcceptInputType_animateOnRelease: unknown;
static ngAcceptInputType_hideBaseOnDrag: unknown;
static ngAcceptInputType_removable: unknown;
static ngAcceptInputType_selectable: unknown;
static ngAcceptInputType_disabled: unknown;
static ngAcceptInputType_selected: unknown;
}
interface IBaseChipsAreaEventArgs {
originalEvent: IDragBaseEventArgs | IDropBaseEventArgs | KeyboardEvent | MouseEvent | TouchEvent;
owner: IgxChipsAreaComponent;
}
interface IChipsAreaReorderEventArgs extends IBaseChipsAreaEventArgs {
chipsArray: IgxChipComponent[];
}
interface IChipsAreaSelectEventArgs extends IBaseChipsAreaEventArgs {
newSelection: IgxChipComponent[];
}
/**
* The chip area allows you to perform more complex scenarios with chips that require interaction,
* like dragging, selection, navigation, etc.
*
* @igxModule IgxChipsModule
*
* @igxTheme igx-chip-theme
*
* @igxKeywords chip area, chip
*
* @igxGroup display
*
* @example
* ```html
* <igx-chips-area>
* <igx-chip *ngFor="let chip of chipList" [id]="chip.id">
* <span>{{chip.text}}</span>
* </igx-chip>
* </igx-chips-area>
* ```
*/
declare class IgxChipsAreaComponent implements DoCheck, AfterViewInit, OnDestroy {
cdr: ChangeDetectorRef;
element: ElementRef<any>;
private _iterableDiffers;
/**
* Returns the `role` attribute of the chips area.
*
* @example
* ```typescript
* let chipsAreaRole = this.chipsArea.role;
* ```
*/
role: string;
/**
* Returns the `aria-label` attribute of the chips area.
*
* @example
* ```typescript
* let ariaLabel = this.chipsArea.ariaLabel;
* ```
*
*/
ariaLabel: string;
/**
* Sets the width of the `IgxChipsAreaComponent`.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="300" [height]="10" (onReorder)="chipsOrderChanged($event)"></igx-chips-area>
* ```
*/
width: number;
/** @hidden @internal */
get _widthToRem(): number;
/**
* Sets the height of the `IgxChipsAreaComponent`.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="300" [height]="10" (onReorder)="chipsOrderChanged($event)"></igx-chips-area>
* ```
*/
height: number;
/** @hidden @internal */
get _heightToRem(): number;
/**
* Emits an event when `IgxChipComponent`s in the `IgxChipsAreaComponent` should be reordered.
* Returns an array of `IgxChipComponent`s.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="'300'" [height]="'10'" (onReorder)="changedOrder($event)"></igx-chips-area>
* ```
*/
reorder: EventEmitter<IChipsAreaReorderEventArgs>;
/**
* Emits an event when an `IgxChipComponent` in the `IgxChipsAreaComponent` is selected/deselected.
* Fired after the chips area is initialized if there are initially selected chips as well.
* Returns an array of selected `IgxChipComponent`s and the `IgxChipAreaComponent`.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="'300'" [height]="'10'" (selectionChange)="selection($event)"></igx-chips-area>
* ```
*/
selectionChange: EventEmitter<IChipsAreaSelectEventArgs>;
/**
* Emits an event when an `IgxChipComponent` in the `IgxChipsAreaComponent` is moved.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="'300'" [height]="'10'" (moveStart)="moveStart($event)"></igx-chips-area>
* ```
*/
moveStart: EventEmitter<IBaseChipsAreaEventArgs>;
/**
* Emits an event after an `IgxChipComponent` in the `IgxChipsAreaComponent` is moved.
*
* @example
* ```html
* <igx-chips-area #chipsArea [width]="'300'" [height]="'10'" (moveEnd)="moveEnd($event)"></igx-chips-area>
* ```
*/
moveEnd: EventEmitter<IBaseChipsAreaEventArgs>;
/**
* Holds the `IgxChipComponent` in the `IgxChipsAreaComponent`.
*
* @example
* ```typescript
* ngAfterViewInit(){
* let chips = this.chipsArea.chipsList;
* }
* ```
*/
chipsList: QueryList<IgxChipComponent>;
protected destroy$: Subject<boolean>;
protected hostClass: string;
private modifiedChipsArray;
private _differ;
constructor();
/**
* @hidden
* @internal
*/
ngAfterViewInit(): void;
/**
* @hidden
* @internal
*/
ngDoCheck(): void;
/**
* @hidden
* @internal
*/
ngOnDestroy(): void;
/**
* @hidden
* @internal
*/
protected onChipKeyDown(event: IChipKeyDownEventArgs): void;
/**
* @hidden
* @internal
*/
protected onChipMoveStart(event: IBaseChipEventArgs): void;
/**
* @hidden
* @internal
*/
protected onChipMoveEnd(event: IBaseChipEventArgs): void;
/**
* @hidden
* @internal
*/
protected onChipDragEnter(event: IChipEnterDragAreaEventArgs): void;
/**
* @hidden
* @internal
*/
protected positionChipAtIndex(chipIndex: any, targetIndex: any, shiftRestLeft: any, originalEvent: any): boolean;
/**
* @hidden
* @internal
*/
protected onChipSelectionChange(event: IChipSelectEventArgs): void;
static ɵfac: i0.ɵɵFactoryDeclaration<IgxChipsAreaComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<IgxChipsAreaComponent, "igx-chips-area", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, { "reorder": "reorder"; "selectionChange": "selectionChange"; "moveStart": "moveStart"; "moveEnd": "moveEnd"; }, ["chipsList"], ["*"], true, never>;
}
declare const IGX_CHIPS_DIRECTIVES: readonly [typeof IgxChipsAreaComponent, typeof IgxChipComponent, typeof IgxPrefixDirective, typeof IgxSuffixDirective];
/**
* @hidden
* IMPORTANT: The following is NgModule exported for backwards-compatibility before standalone components
*/
declare class IgxChipsModule {
static ɵfac: i0.ɵɵFactoryDeclaration<IgxChipsModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<IgxChipsModule, never, [typeof IgxChipsAreaComponent, typeof IgxChipComponent, typeof i3.IgxPrefixDirective, typeof i3.IgxSuffixDirective], [typeof IgxChipsAreaComponent, typeof IgxChipComponent, typeof i3.IgxPrefixDirective, typeof i3.IgxSuffixDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<IgxChipsModule>;
}
export { IGX_CHIPS_DIRECTIVES, IgxChipComponent, IgxChipTypeVariant, IgxChipsAreaComponent, IgxChipsModule };
export type { IBaseChipEventArgs, IBaseChipsAreaEventArgs, IChipClickEventArgs, IChipEnterDragAreaEventArgs, IChipKeyDownEventArgs, IChipSelectEventArgs, IChipsAreaReorderEventArgs, IChipsAreaSelectEventArgs };