UNPKG

@progress/kendo-angular-toolbar

Version:

Kendo UI Angular Toolbar component - a single UI element that organizes buttons and other navigation elements

153 lines (152 loc) 6.6 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, ElementRef, HostBinding, Input, Renderer2, NgZone, Output, EventEmitter } from '@angular/core'; import { Subscription } from 'rxjs'; import { caretAltLeftIcon, caretAltRightIcon } from '@progress/kendo-svg-icons'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { IconWrapperComponent } from '@progress/kendo-angular-icons'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; const DIRECTION_CLASSES = { left: 'caret-alt-left', right: 'caret-alt-right' }; /** * @hidden */ export class ToolbarScrollableButtonComponent { host; renderer; ngZone; localization; get prevClass() { return this.prev; } get nextClass() { return !this.prev; } role = 'button'; prev = false; overflow; onClick = new EventEmitter(); get iconClass() { return this.scrollButtonIconClass; } get customIconClass() { return this.customScrollButtonIconClass; } get svgIcon() { return this.scrollButtonSVGIcon; } caretAltLeftIcon = caretAltLeftIcon; caretAltRightIcon = caretAltRightIcon; subs = new Subscription(); constructor(host, renderer, ngZone, localization) { this.host = host; this.renderer = renderer; this.ngZone = ngZone; this.localization = localization; } ngAfterViewInit() { this.ngZone.runOutsideAngular(() => { this.subs.add(this.renderer.listen(this.host.nativeElement, 'click', this.clickHandler)); }); } ngOnDestroy() { this.subs.unsubscribe(); } clickHandler = () => { const buttonType = this.prev ? 'prev' : 'next'; this.onClick.emit(buttonType); }; get scrollButtonIconClass() { const defaultPrevIcon = !this.localization.rtl ? DIRECTION_CLASSES.left : DIRECTION_CLASSES.right; const defaultNextIcon = !this.localization.rtl ? DIRECTION_CLASSES.right : DIRECTION_CLASSES.left; if (typeof this.overflow === 'object') { const prevIcon = typeof this.overflow.prevButtonIcon === 'undefined' ? defaultPrevIcon : ''; const nextIcon = typeof this.overflow.nextButtonIcon === 'undefined' ? defaultNextIcon : ''; if (prevIcon && this.prev) { return prevIcon; } else if (nextIcon && !this.prev) { return nextIcon; } } } get customScrollButtonIconClass() { if (typeof this.overflow === 'object') { const prevIcon = this.overflow.prevButtonIcon; const nextIcon = this.overflow.nextButtonIcon; if (prevIcon && this.prev) { return `k-icon ${prevIcon}`; } if (nextIcon && !this.prev) { return `k-icon ${nextIcon}`; } } } get scrollButtonSVGIcon() { const defaultPrevSVGIcon = !this.localization.rtl ? this.caretAltLeftIcon : this.caretAltRightIcon; const defaultNextSVGIcon = !this.localization.rtl ? this.caretAltRightIcon : this.caretAltLeftIcon; if (typeof this.overflow === 'object') { const prevIcon = this.overflow.prevSVGButtonIcon !== undefined ? this.overflow.prevSVGButtonIcon : defaultPrevSVGIcon; const nextIcon = this.overflow.nextSVGButtonIcon !== undefined ? this.overflow.nextSVGButtonIcon : defaultNextSVGIcon; if (prevIcon || nextIcon) { return this.prev ? prevIcon : nextIcon; } } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToolbarScrollableButtonComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ToolbarScrollableButtonComponent, isStandalone: true, selector: "[kendoToolbarScrollableButton]", inputs: { prev: "prev", overflow: "overflow" }, outputs: { onClick: "onClick" }, host: { properties: { "class.k-toolbar-prev": "this.prevClass", "class.k-toolbar-next": "this.nextClass", "attr.role": "this.role" } }, ngImport: i0, template: ` <kendo-icon-wrapper [name]="iconClass" [customFontClass]="customIconClass" [svgIcon]="svgIcon" innerCssClass="k-button-icon" > </kendo-icon-wrapper> `, isInline: true, dependencies: [{ kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToolbarScrollableButtonComponent, decorators: [{ type: Component, args: [{ template: ` <kendo-icon-wrapper [name]="iconClass" [customFontClass]="customIconClass" [svgIcon]="svgIcon" innerCssClass="k-button-icon" > </kendo-icon-wrapper> `, // eslint-disable-next-line @angular-eslint/component-selector selector: '[kendoToolbarScrollableButton]', standalone: true, imports: [IconWrapperComponent] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.LocalizationService }]; }, propDecorators: { prevClass: [{ type: HostBinding, args: ['class.k-toolbar-prev'] }], nextClass: [{ type: HostBinding, args: ['class.k-toolbar-next'] }], role: [{ type: HostBinding, args: ['attr.role'] }], prev: [{ type: Input }], overflow: [{ type: Input }], onClick: [{ type: Output }] } });