UNPKG

@progress/kendo-angular-conversational-ui

Version:

Kendo UI for Angular Conversational UI components

151 lines (142 loc) 5.88 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, forwardRef, HostBinding, Input } from '@angular/core'; import { ChatItem } from './chat-item'; import { MessageTemplateDirective } from './message-template.directive'; import { IntlService } from '@progress/kendo-angular-intl'; import { NgIf, NgTemplateOutlet } from '@angular/common'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-intl"; // eslint-disable no-forward-ref /** * @hidden */ export class MessageComponent extends ChatItem { element; intl; message; tabbable; template; cssClass = true; selected; get tabIndex() { return this.tabbable ? '0' : '-1'; } constructor(element, intl) { super(); this.element = element; this.intl = intl; } formatTimeStamp(date) { return this.intl.formatDate(date, { datetime: 'short' }); } focus() { this.element.nativeElement.focus(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageComponent, deps: [{ token: i0.ElementRef }, { token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MessageComponent, isStandalone: true, selector: "kendo-chat-message", inputs: { message: "message", tabbable: "tabbable", template: "template" }, host: { properties: { "class.k-message": "this.cssClass", "class.k-selected": "this.selected", "class.k-focus": "this.selected", "attr.tabIndex": "this.tabIndex" } }, providers: [{ provide: ChatItem, useExisting: forwardRef(() => MessageComponent) }], usesInheritance: true, ngImport: i0, template: ` <time [attr.aria-hidden]="!selected" class="k-message-time" *ngIf="message.timestamp" > {{ formatTimeStamp(message.timestamp) }} </time> <ng-container *ngIf="!message.typing; else typing"> <div class="k-chat-bubble" *ngIf="template"> <ng-container *ngTemplateOutlet="template.templateRef; context: { $implicit: message };" > </ng-container> </div> <div class="k-chat-bubble" *ngIf="!template && message.text"> {{message.text}} </div> </ng-container> <span class="k-message-status" *ngIf="message.status" > {{ message.status }} </span> <ng-template #typing> <div class="k-chat-bubble"> <div class="k-typing-indicator"> <span></span> <span></span> <span></span> </div> </div> </ng-template> `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-chat-message', providers: [{ provide: ChatItem, useExisting: forwardRef(() => MessageComponent) }], template: ` <time [attr.aria-hidden]="!selected" class="k-message-time" *ngIf="message.timestamp" > {{ formatTimeStamp(message.timestamp) }} </time> <ng-container *ngIf="!message.typing; else typing"> <div class="k-chat-bubble" *ngIf="template"> <ng-container *ngTemplateOutlet="template.templateRef; context: { $implicit: message };" > </ng-container> </div> <div class="k-chat-bubble" *ngIf="!template && message.text"> {{message.text}} </div> </ng-container> <span class="k-message-status" *ngIf="message.status" > {{ message.status }} </span> <ng-template #typing> <div class="k-chat-bubble"> <div class="k-typing-indicator"> <span></span> <span></span> <span></span> </div> </div> </ng-template> `, standalone: true, imports: [NgIf, NgTemplateOutlet] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.IntlService }]; }, propDecorators: { message: [{ type: Input }], tabbable: [{ type: Input }], template: [{ type: Input }], cssClass: [{ type: HostBinding, args: ['class.k-message'] }], selected: [{ type: HostBinding, args: ['class.k-selected'] }, { type: HostBinding, args: ['class.k-focus'] }], tabIndex: [{ type: HostBinding, args: ['attr.tabIndex'] }] } });