@progress/kendo-angular-treelist
Version:
Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.
165 lines (164 loc) • 7.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
*-------------------------------------------------------------------------------------------*/
import { Component, Input, Output, EventEmitter, ChangeDetectorRef, ElementRef } from '@angular/core';
import { ColumnInfoService } from '../common/column-info.service';
import { LocalizationService } from "@progress/kendo-angular-l10n";
import { ColumnMenuItemBase } from './column-menu-item-base';
import { columnsIcon } from '@progress/kendo-svg-icons';
import { ColumnListComponent } from './column-list.component';
import { ColumnMenuItemContentTemplateDirective } from './column-menu-item-content-template.directive';
import { ColumnMenuItemComponent } from './column-menu-item.component';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-l10n";
import * as i2 from "../common/column-info.service";
/**
*
* Represents the Kendo UI for Angular TreeList column-menu item for chaging the visibility of the columns. [See example](slug:columnmenu_treelist#toc-column-chooser-item).
*
* Place this component inside a [`ColumnMenuTemplate`]({% slug api_treelist_columnmenutemplatedirective %}) directive to enable the feature.
* Set the [`ColumnMenuService`]({% slug api_treelist_columnmenuservice %}) and `column` inputs using the values passed by the template.
*
* @example
* ```html
* <kendo-treelist [columnMenu]="true" ...>
* <ng-template kendoTreeListColumnMenuTemplate let-service="service" let-column="column">
* <kendo-treelist-columnmenu-chooser [column]="column" [service]="service">
* </kendo-treelist-columnmenu-chooser>
* </ng-template>
* </kendo-treelist>
* ```
*/
export class ColumnMenuChooserComponent extends ColumnMenuItemBase {
localization;
columnInfoService;
changeDetector;
hostElement;
/**
* Fires when the content expands.
*/
expand = new EventEmitter();
/**
* Fires when the content collapses.
*/
collapse = new EventEmitter();
/**
* Specifies if the content is expanded.
* @default false
*/
expanded = false;
/**
* @hidden
*/
isLast = false;
/**
* @hidden
*/
actionsClass = 'k-actions k-actions-stretched k-actions-horizontal';
get columns() {
return this.columnInfoService.leafNamedColumns;
}
columnsIcon = columnsIcon;
constructor(localization, columnInfoService, changeDetector, hostElement) {
super();
this.localization = localization;
this.columnInfoService = columnInfoService;
this.changeDetector = changeDetector;
this.hostElement = hostElement;
}
/**
* @hidden
*/
onApply(changed) {
this.close();
if (changed.length) {
this.changeDetector.markForCheck();
this.columnInfoService.changeVisibility(changed);
}
}
/**
* @hidden
*/
onCollapse() {
this.expanded = false;
if (this.isLast) {
this.service.menuTabbingService.lastFocusable = this.hostElement.nativeElement.querySelector('.k-columnmenu-item');
}
this.collapse.emit();
}
/**
* @hidden
*/
onExpand() {
this.expanded = true;
this.expand.emit();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuChooserComponent, deps: [{ token: i1.LocalizationService }, { token: i2.ColumnInfoService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnMenuChooserComponent, isStandalone: true, selector: "kendo-treelist-columnmenu-chooser", inputs: { expanded: "expanded", isLast: "isLast" }, outputs: { expand: "expand", collapse: "collapse" }, usesInheritance: true, ngImport: i0, template: `
<kendo-treelist-columnmenu-item
[text]="localization.get('columns')"
icon="columns"
[svgIcon]="columnsIcon"
[expanded]="expanded"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoTreeListColumnMenuItemContentTemplate>
<kendo-treelist-columnlist
[applyText]="localization.get('columnsApply')"
[resetText]="localization.get('columnsReset')"
[ariaLabel]="localization.get('columns')"
[columns]="columns"
[autoSync]="false"
[allowHideAll]="false"
[actionsClass]="actionsClass"
[isLast]="isLast"
[isExpanded]="expanded"
[service]="service"
(apply)="onApply($event)">
</kendo-treelist-columnlist>
</ng-template>
</kendo-treelist-columnmenu-item>
`, isInline: true, dependencies: [{ kind: "component", type: ColumnMenuItemComponent, selector: "kendo-treelist-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }, { kind: "directive", type: ColumnMenuItemContentTemplateDirective, selector: "[kendoTreeListColumnMenuItemContentTemplate]" }, { kind: "component", type: ColumnListComponent, selector: "kendo-treelist-columnlist", inputs: ["columns", "autoSync", "ariaLabel", "allowHideAll", "applyText", "resetText", "actionsClass", "isLast", "isExpanded", "service"], outputs: ["reset", "apply", "columnChange"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuChooserComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-treelist-columnmenu-chooser',
template: `
<kendo-treelist-columnmenu-item
[text]="localization.get('columns')"
icon="columns"
[svgIcon]="columnsIcon"
[expanded]="expanded"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoTreeListColumnMenuItemContentTemplate>
<kendo-treelist-columnlist
[applyText]="localization.get('columnsApply')"
[resetText]="localization.get('columnsReset')"
[ariaLabel]="localization.get('columns')"
[columns]="columns"
[autoSync]="false"
[allowHideAll]="false"
[actionsClass]="actionsClass"
[isLast]="isLast"
[isExpanded]="expanded"
[service]="service"
(apply)="onApply($event)">
</kendo-treelist-columnlist>
</ng-template>
</kendo-treelist-columnmenu-item>
`,
standalone: true,
imports: [ColumnMenuItemComponent, ColumnMenuItemContentTemplateDirective, ColumnListComponent]
}]
}], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i2.ColumnInfoService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { expand: [{
type: Output
}], collapse: [{
type: Output
}], expanded: [{
type: Input
}], isLast: [{
type: Input
}] } });