UNPKG

@progress/kendo-angular-conversational-ui

Version:

Kendo UI for Angular Conversational UI components

82 lines (81 loc) 4.4 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 { chevronLeftIcon, chevronRightIcon } 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: 'chevron-left', right: 'chevron-right', }; /** * @hidden */ export class ChatScrollableButtonComponent { host; renderer; ngZone; localization; role = 'button'; prev = false; onClick = new EventEmitter(); get scrollButtonIconClass() { const defaultPrevIcon = !this.localization.rtl ? DIRECTION_CLASSES.left : DIRECTION_CLASSES.right; const defaultNextIcon = !this.localization.rtl ? DIRECTION_CLASSES.right : DIRECTION_CLASSES.left; return this.prev ? defaultPrevIcon : defaultNextIcon; } get scrollButtonSVGIcon() { const defaultPrevSVGIcon = !this.localization.rtl ? this.chevronLeftIcon : this.chevronRightIcon; const defaultNextSVGIcon = !this.localization.rtl ? this.chevronRightIcon : this.chevronLeftIcon; return this.prev ? defaultPrevSVGIcon : defaultNextSVGIcon; } chevronLeftIcon = chevronLeftIcon; chevronRightIcon = chevronRightIcon; 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); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ChatScrollableButtonComponent, 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: "18.2.14", type: ChatScrollableButtonComponent, isStandalone: true, selector: "[kendoChatScrollableButton]", inputs: { prev: "prev" }, outputs: { onClick: "onClick" }, host: { properties: { "attr.role": "this.role" } }, ngImport: i0, template: ` <kendo-icon-wrapper [name]="scrollButtonIconClass" [svgIcon]="scrollButtonSVGIcon" 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: "18.2.14", ngImport: i0, type: ChatScrollableButtonComponent, decorators: [{ type: Component, args: [{ template: ` <kendo-icon-wrapper [name]="scrollButtonIconClass" [svgIcon]="scrollButtonSVGIcon" innerCssClass="k-button-icon"> </kendo-icon-wrapper> `, // eslint-disable-next-line @angular-eslint/component-selector selector: '[kendoChatScrollableButton]', standalone: true, imports: [IconWrapperComponent], }] }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.LocalizationService }], propDecorators: { role: [{ type: HostBinding, args: ['attr.role'] }], prev: [{ type: Input }], onClick: [{ type: Output }] } });