@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
186 lines (185 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
*-------------------------------------------------------------------------------------------*/
import { Component, Input, Output, EventEmitter, ElementRef } from '@angular/core';
import { setColumnPositionIcon } from '@progress/kendo-svg-icons';
import { ContextService } from '../common/provider.service';
import { ColumnMenuItemBase } from './column-menu-item-base';
import { ColumnMenuStickComponent } from './column-menu-stick.component';
import { ColumnMenuLockComponent } from './column-menu-lock.component';
import { NgIf } from '@angular/common';
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 "../common/provider.service";
/**
* Represents the column-menu item which combines the lock and sticky column functionalities.
*
* The component can be placed inside a [ColumnMenuTemplate]({% slug api_grid_columnmenutemplatedirective %}) directive.
* To register the component as a known column menu item, set the [ColumnMenuService]({% slug api_grid_columnmenuservice %}) that is passed by
* the template to the service input of the `kendo-grid-columnmenu-position` component. [See example](slug:columnmenu_grid#toc-set-column-position-item).
*
* @example
* ```html
* <kendo-grid [data]="data" [columnMenu]="true" ...>
* <ng-template kendoGridColumnMenuTemplate let-service="service" let-column="column">
* <kendo-grid-columnmenu-position [service]="service" [showLock]="true" [showStick]="true">
* </kendo-grid-columnmenu-position>
* </ng-template>
* </kendo-grid>
* ```
*/
export class ColumnMenuPositionComponent extends ColumnMenuItemBase {
ctx;
hostElement;
/**
* Fires when the content is expanded.
*/
expand = new EventEmitter();
/**
* Fires when the content is collapsed.
*/
collapse = new EventEmitter();
/**
* Specifies if the content is expanded.
* @default false
*/
expanded = false;
/**
* Specifies if the lock column item is displayed.
*/
showLock;
/**
* Specifies if the stick column item is displayed.
*/
showStick;
/**
* @hidden
*/
actionsClass = 'k-actions';
/**
* @hidden
*/
set isLast(value) {
this.service.menuTabbingService.lastFocusable = this.getLastFocusableItem();
this._isLast = value;
}
/**
* @hidden
*/
get isLast() {
return this._isLast;
}
setColumnPositionIcon = setColumnPositionIcon;
_isLast = false;
constructor(ctx, hostElement) {
super();
this.ctx = ctx;
this.hostElement = hostElement;
}
/**
* @hidden
*/
onTab(e, isLastItem) {
if (this.isLast && isLastItem) {
e.preventDefault();
e.stopImmediatePropagation();
if (this.service) {
this.service.menuTabbingService.firstFocusable.focus();
}
}
}
/**
* @hidden
*/
onCollapse() {
this.expanded = false;
if (this.isLast) {
this.service.menuTabbingService.lastFocusable = this.getLastFocusableItem();
}
this.collapse.emit();
}
/**
* @hidden
*/
onExpand() {
this.expanded = true;
if (this.isLast) {
this.service.menuTabbingService.lastFocusable = this.getLastFocusableItem();
}
this.expand.emit();
}
getLastFocusableItem() {
const menuItems = this.hostElement.nativeElement.querySelectorAll('.k-columnmenu-item');
const lastFocusableIndex = this.expanded ? menuItems.length - 1 : 0;
return menuItems[lastFocusableIndex];
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuPositionComponent, deps: [{ token: i1.ContextService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnMenuPositionComponent, isStandalone: true, selector: "kendo-grid-columnmenu-position", inputs: { expanded: "expanded", showLock: "showLock", showStick: "showStick", isLast: "isLast" }, outputs: { expand: "expand", collapse: "collapse" }, usesInheritance: true, ngImport: i0, template: `
<kendo-grid-columnmenu-item
[text]="ctx.localization.get('setColumnPosition')"
icon="set-column-position"
[svgIcon]="setColumnPositionIcon"
[expanded]="expanded"
(keydown.tab)="onTab($event, !expanded)"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoGridColumnMenuItemContentTemplate>
<kendo-grid-columnmenu-lock
*ngIf="showLock"
(keydown.tab)="onTab($event, !showStick)"
[service]="service">
</kendo-grid-columnmenu-lock>
<kendo-grid-columnmenu-stick
*ngIf="showStick"
(keydown.tab)="onTab($event, true)"
[service]="service">
</kendo-grid-columnmenu-stick>
</ng-template>
</kendo-grid-columnmenu-item>
`, isInline: true, dependencies: [{ kind: "component", type: ColumnMenuItemComponent, selector: "kendo-grid-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }, { kind: "directive", type: ColumnMenuItemContentTemplateDirective, selector: "[kendoGridColumnMenuItemContentTemplate]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ColumnMenuLockComponent, selector: "kendo-grid-columnmenu-lock" }, { kind: "component", type: ColumnMenuStickComponent, selector: "kendo-grid-columnmenu-stick" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuPositionComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-grid-columnmenu-position',
template: `
<kendo-grid-columnmenu-item
[text]="ctx.localization.get('setColumnPosition')"
icon="set-column-position"
[svgIcon]="setColumnPositionIcon"
[expanded]="expanded"
(keydown.tab)="onTab($event, !expanded)"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoGridColumnMenuItemContentTemplate>
<kendo-grid-columnmenu-lock
*ngIf="showLock"
(keydown.tab)="onTab($event, !showStick)"
[service]="service">
</kendo-grid-columnmenu-lock>
<kendo-grid-columnmenu-stick
*ngIf="showStick"
(keydown.tab)="onTab($event, true)"
[service]="service">
</kendo-grid-columnmenu-stick>
</ng-template>
</kendo-grid-columnmenu-item>
`,
standalone: true,
imports: [ColumnMenuItemComponent, ColumnMenuItemContentTemplateDirective, NgIf, ColumnMenuLockComponent, ColumnMenuStickComponent]
}]
}], ctorParameters: function () { return [{ type: i1.ContextService }, { type: i0.ElementRef }]; }, propDecorators: { expand: [{
type: Output
}], collapse: [{
type: Output
}], expanded: [{
type: Input
}], showLock: [{
type: Input
}], showStick: [{
type: Input
}], isLast: [{
type: Input
}] } });