@progress/kendo-angular-listview
Version:
Kendo UI Angular listview component
95 lines (94 loc) • 4.83 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Component, HostListener, ElementRef, Renderer2 as Renderer, NgZone } from '@angular/core';
import { Button } from '@progress/kendo-angular-buttons';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { EditService } from '../edit.service';
import { getClosestListItemIndex } from '../../utils';
import { NgClass } from '@angular/common';
import { IconWrapperComponent } from '@progress/kendo-angular-icons';
import * as i0 from "@angular/core";
import * as i1 from "../edit.service";
import * as i2 from "@progress/kendo-angular-l10n";
/**
* Represents the remove command button directive of the Kendo UI ListView for Angular.
* Provides the `remove` command of the ListView. You can apply this directive to any `button` element
* inside a [`EditTemplateDirective`]({% slug api_listview_edittemplatedirective %}) template.
* When you click an associated button with the directive, the
* [`remove`]({% slug api_listview_listviewcomponent %}#toc-remove) event
* triggers ([see example]({% slug editing_listview %})).
*
* @example
* ```html
* <kendo-listview>
* <ng-template kendoListViewEditTemplate>
* <button kendoListViewRemoveCommand>Remove item</button>
* </ng-template>
* </kendo-listview>
* ```
*/
export class RemoveCommandDirective extends Button {
editService;
elementRef;
/**
* @hidden
*/
clickHandler(e) {
e.preventDefault();
const index = getClosestListItemIndex(this.elementRef.nativeElement);
this.editService.remove(index);
}
constructor(editService, element, renderer, localization, ngZone) {
super(element, renderer, null, localization, ngZone);
this.editService = editService;
this.elementRef = element;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RemoveCommandDirective, deps: [{ token: i1.EditService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i2.LocalizationService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: RemoveCommandDirective, isStandalone: true, selector: "[kendoListViewRemoveCommand]", host: { listeners: { "click": "clickHandler($event)" } }, usesInheritance: true, ngImport: i0, template: `
(icon || svgIcon) {
<kendo-icon-wrapper
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
}
(imageUrl) {
<span class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
}
(iconClass) {
<span class="k-button-icon" [ngClass]="iconClass"></span>
}
<span class="k-button-text"><ng-content></ng-content></span>
`, isInline: true, dependencies: [{ kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RemoveCommandDirective, decorators: [{
type: Component,
args: [{
selector: '[kendoListViewRemoveCommand]',
template: `
(icon || svgIcon) {
<kendo-icon-wrapper
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
}
(imageUrl) {
<span class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
}
(iconClass) {
<span class="k-button-icon" [ngClass]="iconClass"></span>
}
<span class="k-button-text"><ng-content></ng-content></span>
`,
standalone: true,
imports: [IconWrapperComponent, NgClass]
}]
}], ctorParameters: () => [{ type: i1.EditService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i2.LocalizationService }, { type: i0.NgZone }], propDecorators: { clickHandler: [{
type: HostListener,
args: ['click', ['$event']]
}] } });