@progress/kendo-angular-conversational-ui
Version:
Kendo UI for Angular Conversational UI components
158 lines (157 loc) • 7.22 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* 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 { NgIf, NgFor } from '@angular/common';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { guid } from '@progress/kendo-angular-common';
import { chevronDownIcon, chevronUpIcon } from '@progress/kendo-svg-icons';
import { ButtonComponent } from '@progress/kendo-angular-buttons';
import { TextAreaComponent } from '@progress/kendo-angular-inputs';
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 **Prompt** view of the AIPrompt.
*
* @example
* ```html
* <kendo-aiprompt-prompt-view
* buttonText="My prompt view">
* </kendo-aiprompt-prompt-view>
* ```
*/
export class PromptViewComponent extends BaseView {
service;
constructor(localization, service) {
super('prompt', localization);
this.service = service;
}
/**
* @hidden
*/
get suggestionsIcons() {
return this.showSuggestions ?
{ font: 'chevron-up', svg: chevronUpIcon } :
{ font: 'chevron-down', svg: chevronDownIcon };
}
/**
* @hidden
*/
showSuggestions = true;
/**
* @hidden
*/
contentId = `k-prompt-suggestions-${guid()}`;
/**
* @hidden
*/
get promptSuggestions() {
return this.service.promptSuggestions;
}
/**
*
* @hidden
*/
set textAreaValue(value) {
this.service.promptValue = value;
}
get textAreaValue() {
return this.service.promptValue;
}
/**
* @hidden
*/
suggestionClick(suggestion) {
this.textAreaValue = this.service.promptValue = suggestion;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PromptViewComponent, deps: [{ token: i1.LocalizationService }, { token: i2.AIPromptService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PromptViewComponent, isStandalone: true, selector: "kendo-aiprompt-prompt-view", providers: [
{
provide: BaseView,
useExisting: forwardRef(() => PromptViewComponent)
}
], usesInheritance: true, ngImport: i0, template: `
<ng-template
<kendo-textarea
[ ]="messageFor('promptPlaceholder')"
[ ]="1"
[(value)]="textAreaValue">
</kendo-textarea>
<div *ngIf="promptSuggestions"
class="k-prompt-expander">
<button kendoButton
[ ]="contentId"
[ ]="showSuggestions"
fillMode="flat"
[ ]="suggestionsIcons.font"
[ ]="suggestionsIcons.svg"
type="button"
(click)="showSuggestions = !showSuggestions">
{{messageFor('promptSuggestions')}}
</button>
<div *ngIf="showSuggestions"
class="k-prompt-expander-content"
role="list"
[ ]="contentId">
<div *ngFor="let suggestion of promptSuggestions"
class="k-prompt-suggestion"
role="listitem"
(click)="suggestionClick(suggestion)">
{{suggestion}}
</div>
</div>
</div>
</ng-template>
`, isInline: true, dependencies: [{ kind: "component", type: TextAreaComponent, selector: "kendo-textarea", inputs: ["focusableId", "flow", "inputAttributes", "adornmentsOrientation", "rows", "cols", "maxlength", "tabindex", "tabIndex", "resizable", "size", "rounded", "fillMode", "showPrefixSeparator", "showSuffixSeparator"], outputs: ["focus", "blur", "valueChange"], exportAs: ["kendoTextArea"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PromptViewComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-aiprompt-prompt-view',
providers: [
{
provide: BaseView,
useExisting: forwardRef(() => PromptViewComponent)
}
],
template: `
<ng-template
<kendo-textarea
[ ]="messageFor('promptPlaceholder')"
[ ]="1"
[(value)]="textAreaValue">
</kendo-textarea>
<div *ngIf="promptSuggestions"
class="k-prompt-expander">
<button kendoButton
[ ]="contentId"
[ ]="showSuggestions"
fillMode="flat"
[ ]="suggestionsIcons.font"
[ ]="suggestionsIcons.svg"
type="button"
(click)="showSuggestions = !showSuggestions">
{{messageFor('promptSuggestions')}}
</button>
<div *ngIf="showSuggestions"
class="k-prompt-expander-content"
role="list"
[ ]="contentId">
<div *ngFor="let suggestion of promptSuggestions"
class="k-prompt-suggestion"
role="listitem"
(click)="suggestionClick(suggestion)">
{{suggestion}}
</div>
</div>
</div>
</ng-template>
`,
standalone: true,
imports: [TextAreaComponent, NgIf, ButtonComponent, NgFor]
}]
}], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i2.AIPromptService }]; } });