UNPKG

@progress/kendo-angular-dialog

Version:
169 lines (168 loc) 7.86 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Component, EventEmitter, HostBinding, TemplateRef, Input, Output, ElementRef } from '@angular/core'; import { NgIf, NgFor, NgClass, NgTemplateOutlet } from '@angular/common'; import { KENDO_BUTTON } from '@progress/kendo-angular-buttons'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-buttons"; /** * Specifies the action buttons of the Dialog * ([see example]({% slug actionbuttons_dialog %})). */ export class DialogActionsComponent { el; /** * Allows the declarative specification of the actions. */ set actions(value) { if (value instanceof TemplateRef) { this.actionsTemplate = value; } else if (Array.isArray(value)) { this.actionsArray = value; } else { throw new Error('"actions" must be either TemplateRef or DialogAction[] instance.'); } } /** * @hidden */ actionsArray; /** * @hidden */ actionsTemplate; /** * Specifies the possible layout of the action buttons. * @default 'stretched' */ layout = 'stretched'; /** * Fires when the user clicks an action button. */ action = new EventEmitter(); hostClasses = true; get startClassName() { return this.layout === 'start'; } get centerClassName() { return this.layout === 'center'; } get endClassName() { return this.layout === 'end'; } get stretchedClassName() { return this.layout === 'stretched'; } constructor(el) { this.el = el; } /** * @hidden */ onButtonClick(action, _e) { this.action.emit(action); } /** * @hidden */ isDivider(action) { return action === 'spacer'; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DialogActionsComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: DialogActionsComponent, isStandalone: true, selector: "kendo-dialog-actions", inputs: { actions: "actions", layout: "layout" }, outputs: { action: "action" }, host: { properties: { "class.k-actions": "this.hostClasses", "class.k-actions-horizontal": "this.hostClasses", "class.k-window-actions": "this.hostClasses", "class.k-dialog-actions": "this.hostClasses", "class.k-actions-start": "this.startClassName", "class.k-actions-center": "this.centerClassName", "class.k-actions-end": "this.endClassName", "class.k-actions-stretched": "this.stretchedClassName" } }, ngImport: i0, template: ` <ng-content *ngIf="!actions"></ng-content> <ng-container *ngIf="actionsArray; else actionTemplate"> <ng-container *ngFor="let action of actionsArray"> <ng-container *ngIf="isDivider(action); else defaultAction"> <span class="k-spacer"></span> </ng-container> <ng-template #defaultAction> <button type="button" kendoButton [disabled]="action.disabled" [fillMode]="action.fillMode" [themeColor]="action.themeColor" [ngClass]="action.cssClass" (click)="onButtonClick(action, $event)" [attr.aria-label]="action.text" [svgIcon]="action.svgIcon" [icon]="action.icon" > {{ action.text }} </button> </ng-template> </ng-container> </ng-container> <ng-template #actionTemplate [ngTemplateOutlet]="actionsTemplate"></ng-template> `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i1.ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DialogActionsComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-dialog-actions', template: ` <ng-content *ngIf="!actions"></ng-content> <ng-container *ngIf="actionsArray; else actionTemplate"> <ng-container *ngFor="let action of actionsArray"> <ng-container *ngIf="isDivider(action); else defaultAction"> <span class="k-spacer"></span> </ng-container> <ng-template #defaultAction> <button type="button" kendoButton [disabled]="action.disabled" [fillMode]="action.fillMode" [themeColor]="action.themeColor" [ngClass]="action.cssClass" (click)="onButtonClick(action, $event)" [attr.aria-label]="action.text" [svgIcon]="action.svgIcon" [icon]="action.icon" > {{ action.text }} </button> </ng-template> </ng-container> </ng-container> <ng-template #actionTemplate [ngTemplateOutlet]="actionsTemplate"></ng-template> `, standalone: true, imports: [NgIf, NgFor, NgClass, NgTemplateOutlet, KENDO_BUTTON] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { actions: [{ type: Input }], layout: [{ type: Input }], action: [{ type: Output }], hostClasses: [{ type: HostBinding, args: ['class.k-actions'] }, { type: HostBinding, args: ['class.k-actions-horizontal'] }, { type: HostBinding, args: ['class.k-window-actions'] }, { type: HostBinding, args: ['class.k-dialog-actions'] }], startClassName: [{ type: HostBinding, args: ['class.k-actions-start'] }], centerClassName: [{ type: HostBinding, args: ['class.k-actions-center'] }], endClassName: [{ type: HostBinding, args: ['class.k-actions-end'] }], stretchedClassName: [{ type: HostBinding, args: ['class.k-actions-stretched'] }] } });