UNPKG

@progress/kendo-angular-conversational-ui

Version:

Kendo UI for Angular Conversational UI components

101 lines (100 loc) 4.34 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, forwardRef } from '@angular/core'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { PanelBarComponent } from '@progress/kendo-angular-layout'; import { BaseView } from './base-view'; import { AIPromptService } from '../common/aiprompt.service'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; import * as i2 from "../common/aiprompt.service"; /** * Represents the component that renders the **Command** view of the AIPrompt. * * @example * ```html * <kendo-aiprompt-command-view * buttonText="My command view"> * </kendo-aiprompt-command-view> * ``` */ export class CommandViewComponent extends BaseView { service; constructor(localization, service) { super('command', localization); this.service = service; } /** * @hidden */ panelBarItems = []; ngOnInit() { if (this.service.promptCommands) { this.panelBarItems = this.getPanelBarItems(this.service.promptCommands); } } /** * @hidden */ itemClickHandler(ev) { if (ev.item.children) { return; } const selectedCommand = this.service.getFlattenPromptCommands().find(c => c.id == ev.item.id); if (selectedCommand) { const eventArgs = { command: selectedCommand, sender: this.service.aiPrompt, isRetry: false }; this.service.executeEvent.next(eventArgs); } } getPanelBarItems(commands) { return commands.map(c => ({ title: c.text, id: c.id, icon: c.icon, svgIcon: c.svgIcon, children: c.children ? this.getPanelBarItems(c.children) : null })); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CommandViewComponent, deps: [{ token: i1.LocalizationService }, { token: i2.AIPromptService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CommandViewComponent, isStandalone: true, selector: "kendo-aiprompt-command-view", providers: [{ provide: BaseView, useExisting: forwardRef(() => CommandViewComponent) }], usesInheritance: true, ngImport: i0, template: ` <ng-template #content> <kendo-panelbar [items]="panelBarItems" [animate]="false" [selectable]="false" (itemClick)="itemClickHandler($event)" ></kendo-panelbar> </ng-template> `, isInline: true, dependencies: [{ kind: "component", type: PanelBarComponent, selector: "kendo-panelbar", inputs: ["expandMode", "selectable", "animate", "height", "keepItemContent", "items"], outputs: ["stateChange", "select", "expand", "collapse", "itemClick"], exportAs: ["kendoPanelbar"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CommandViewComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-aiprompt-command-view', providers: [{ provide: BaseView, useExisting: forwardRef(() => CommandViewComponent) }], template: ` <ng-template #content> <kendo-panelbar [items]="panelBarItems" [animate]="false" [selectable]="false" (itemClick)="itemClickHandler($event)" ></kendo-panelbar> </ng-template> `, standalone: true, imports: [PanelBarComponent] }] }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i2.AIPromptService }]; } });