@progress/kendo-angular-conversational-ui
Version:
Kendo UI for Angular Conversational UI components
108 lines (107 loc) • 4.77 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-empty-function */
import { Component, EventEmitter, forwardRef, HostBinding, Input, Output, QueryList, ViewChildren } from '@angular/core';
import { NgFor } from '@angular/common';
import { Keys } from '@progress/kendo-angular-common';
import { ChatItem } from './chat-item';
import * as i0 from "@angular/core";
/**
* @hidden
*/
export class SuggestedActionsComponent extends ChatItem {
actions;
tabbable;
dispatch = new EventEmitter();
defaultClass = true;
items;
selectedIndex = 0;
keyHandlers = {
[ ]: (e) => this.changeSelectedIndex(e),
[ ]: (_, action) => this.actionClick(action),
[ ]: (_, action) => this.actionClick(action),
};
isSelected(index) {
return this.selected && this.selectedIndex === index;
}
actionClick(action) {
this.dispatch.next(action);
}
actionKeydown(e, action) {
const handler = this.keyHandlers[e.keyCode];
if (handler) {
handler(e, action);
}
}
focus() { }
changeSelectedIndex(e) {
const offset = e.shiftKey ? -1 : 1;
const prevIndex = this.selectedIndex;
this.selectedIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SuggestedActionsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SuggestedActionsComponent, isStandalone: true, selector: "kendo-chat-suggested-actions", inputs: { actions: "actions", tabbable: "tabbable" }, outputs: { dispatch: "dispatch" }, host: { properties: { "class.k-quick-replies": "this.defaultClass" } }, providers: [{
provide: ChatItem,
useExisting: forwardRef(() => SuggestedActionsComponent)
}], viewQueries: [{ propertyName: "items", predicate: ["item"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
<span
*ngFor="let action of actions; index as index; first as first; last as last"
class="k-quick-reply"
role="button"
[ ]="isSelected(index)"
[ ]="isSelected(index)"
[ ]="first"
[ ]="last"
[ ]="0"
(click)="actionClick(action)"
(keydown)="actionKeydown($event, action)"
>
{{ action.title || action.value }}
</span>
`, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SuggestedActionsComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-chat-suggested-actions',
providers: [{
provide: ChatItem,
useExisting: forwardRef(() => SuggestedActionsComponent)
}],
template: `
<span
*ngFor="let action of actions; index as index; first as first; last as last"
class="k-quick-reply"
role="button"
[ ]="isSelected(index)"
[ ]="isSelected(index)"
[ ]="first"
[ ]="last"
[ ]="0"
(click)="actionClick(action)"
(keydown)="actionKeydown($event, action)"
>
{{ action.title || action.value }}
</span>
`,
standalone: true,
imports: [NgFor]
}]
}], propDecorators: { actions: [{
type: Input
}], tabbable: [{
type: Input
}], dispatch: [{
type: Output
}], defaultClass: [{
type: HostBinding,
args: ['class.k-quick-replies']
}], items: [{
type: ViewChildren,
args: ['item']
}] } });