@progress/kendo-angular-pivotgrid
Version:
PivotGrid package for Angular
201 lines (200 loc) • 8.21 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 */
import { Component, Input, Output, EventEmitter, ContentChild } from '@angular/core';
import { trigger, transition, style, animate, state } from '@angular/animations';
import { ChipMenuItemContentTemplateDirective } from './chip-menu-item-content-template.directive';
import { NgIf, NgTemplateOutlet } from '@angular/common';
import { IconWrapperComponent } from '@progress/kendo-angular-icons';
import * as i0 from "@angular/core";
/**
* @hidden
*
*/
export class ChipMenuItemComponent {
/**
* Fires when the item is clicked.
*/
itemClick = new EventEmitter();
/**
* Fires when the content is expanded.
*/
expand = new EventEmitter();
/**
* Fires when the content is collapsed.
*/
collapse = new EventEmitter();
/**
* Specifies the name of the [font icon](slug:icons#icons-list)
* that will be rendered for the item.
*/
icon;
/**
* Defines an SVGIcon to be rendered for the column menu items.
* The input can take either an [existing Kendo SVG icon](slug:svgicon_list) or a custom one.
*/
svgIcon;
/**
* Specifies the item text.
*/
text;
/**
* Specifies if the item is selected.
*/
selected;
/**
* Specifies if the item is expanded.
*/
expanded;
/**
* Specified if the item is disabled
*/
disabled;
contentTemplate;
get iconClass() {
return `k-i-${this.icon}`;
}
contentState = 'collapsed';
ngOnChanges(changes) {
if (changes.expanded) {
this.updateContentState();
}
}
onClick(e) {
this.itemClick.emit(e);
if (this.contentTemplate) {
this.expanded = !this.expanded;
this.updateContentState();
if (this.expanded) {
this.expand.emit();
}
else {
this.collapse.emit();
}
}
}
updateContentState() {
this.contentState = this.expanded ? 'expanded' : 'collapsed';
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChipMenuItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChipMenuItemComponent, isStandalone: true, selector: "kendo-pivot-chipmenu-item", inputs: { icon: "icon", svgIcon: "svgIcon", text: "text", selected: "selected", expanded: "expanded", disabled: "disabled" }, outputs: { itemClick: "itemClick", expand: "expand", collapse: "collapse" }, queries: [{ propertyName: "contentTemplate", first: true, predicate: ChipMenuItemContentTemplateDirective, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
<div
class="k-columnmenu-item"
(click)="onClick($event)"
(keydown.enter)="onClick($event)"
[ ]="selected"
[ ]="disabled"
role="button"
[ ]="expanded"
[ ]="disabled"
>
<kendo-icon-wrapper
*ngIf="icon"
[ ]="icon"
[ ]="svgIcon"
></kendo-icon-wrapper>
{{ text }}
</div>
<div *ngIf="contentTemplate" [@state]="contentState" [style.overflow]="'hidden'" class="k-columnmenu-item-content">
<ng-container [ngTemplateOutlet]="contentTemplate.templateRef"></ng-container>
<div>
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], animations: [
trigger('state', [
state('collapsed', style({ display: 'none' })),
state('expanded', style({ display: 'block' })),
transition('collapsed => expanded', [
style({
height: '0px',
display: 'block'
}),
animate('100ms ease-in', style({
height: '*'
}))
]),
transition('expanded => collapsed', [
style({
height: '*'
}),
animate('100ms ease-in', style({
height: '0px'
}))
])
])
] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChipMenuItemComponent, decorators: [{
type: Component,
args: [{
animations: [
trigger('state', [
state('collapsed', style({ display: 'none' })),
state('expanded', style({ display: 'block' })),
transition('collapsed => expanded', [
style({
height: '0px',
display: 'block'
}),
animate('100ms ease-in', style({
height: '*'
}))
]),
transition('expanded => collapsed', [
style({
height: '*'
}),
animate('100ms ease-in', style({
height: '0px'
}))
])
])
],
selector: 'kendo-pivot-chipmenu-item',
template: `
<div
class="k-columnmenu-item"
(click)="onClick($event)"
(keydown.enter)="onClick($event)"
[ ]="selected"
[ ]="disabled"
role="button"
[ ]="expanded"
[ ]="disabled"
>
<kendo-icon-wrapper
*ngIf="icon"
[ ]="icon"
[ ]="svgIcon"
></kendo-icon-wrapper>
{{ text }}
</div>
<div *ngIf="contentTemplate" [@state]="contentState" [style.overflow]="'hidden'" class="k-columnmenu-item-content">
<ng-container [ngTemplateOutlet]="contentTemplate.templateRef"></ng-container>
<div>
`,
standalone: true,
imports: [NgIf, IconWrapperComponent, NgTemplateOutlet]
}]
}], propDecorators: { itemClick: [{
type: Output
}], expand: [{
type: Output
}], collapse: [{
type: Output
}], icon: [{
type: Input
}], svgIcon: [{
type: Input
}], text: [{
type: Input
}], selected: [{
type: Input
}], expanded: [{
type: Input
}], disabled: [{
type: Input
}], contentTemplate: [{
type: ContentChild,
args: [ChipMenuItemContentTemplateDirective, { static: false }]
}] } });