@progress/kendo-angular-conversational-ui
Version:
Kendo UI for Angular Conversational UI components
99 lines (98 loc) • 3.66 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 { Input, TemplateRef, Directive, HostBinding, Inject, ViewChild } from '@angular/core';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { isPresent } from '@progress/kendo-angular-common';
import { DEFAULT_ICONS, DEFAULT_SVG_ICONS, MY_TOKEN } from '../utils';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-l10n";
/**
* @hidden
*/
export class BaseView {
viewType;
localization;
hostClasses = true;
/**
* @hidden
*/
template;
constructor(viewType, localization) {
this.viewType = viewType;
this.localization = localization;
if (this.viewType !== 'custom') {
this.icon = DEFAULT_ICONS[this.viewType];
this.svgIcon = DEFAULT_SVG_ICONS[this.viewType];
}
}
/**
* Sets the text for the Toolbar button of the current view.
*/
set buttonText(value) {
this._buttonText = value;
}
get buttonText() {
return isPresent(this._buttonText) ?
this._buttonText :
this.messageFor(`${this.viewType}View`);
}
/**
* Sets the font icon for the Toolbar button of the current view.
*/
set icon(value) {
if (isPresent(value)) {
this._icon = value;
}
else {
this.icon = DEFAULT_ICONS[this.viewType];
}
}
get icon() {
return this._icon;
}
/**
* Sets the SVG icon for the Toolbar button of the current view.
*/
set svgIcon(value) {
if (isPresent(value)) {
this._svgIcon = value;
}
else {
this.svgIcon = DEFAULT_SVG_ICONS[this.viewType];
}
}
get svgIcon() {
return this._svgIcon;
}
/**
* @hidden
*/
messageFor(text) {
return this.localization.get(text);
}
_buttonText;
_icon;
_svgIcon;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BaseView, deps: [{ token: MY_TOKEN }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: BaseView, inputs: { buttonText: "buttonText", icon: "icon", svgIcon: "svgIcon" }, host: { properties: { "class.k-prompt-view": "this.hostClasses" } }, viewQueries: [{ propertyName: "template", first: true, predicate: ["content"], descendants: true, static: true }], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BaseView, decorators: [{
type: Directive
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
type: Inject,
args: [MY_TOKEN]
}] }, { type: i1.LocalizationService }]; }, propDecorators: { hostClasses: [{
type: HostBinding,
args: ['class.k-prompt-view']
}], template: [{
type: ViewChild,
args: ['content', { static: true }]
}], buttonText: [{
type: Input
}], icon: [{
type: Input
}], svgIcon: [{
type: Input
}] } });