UNPKG

@progress/kendo-angular-menu

Version:

Kendo UI Angular Menu component

70 lines (69 loc) 3.15 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, Input, HostBinding, isDevMode } from '@angular/core'; import { ItemsService } from '../services/items.service'; import * as i0 from "@angular/core"; import * as i1 from "../services/items.service"; /** * Represents a directive that can be used in the [`linkTemplate`]({% slug api_menu_itemlinktemplatedirective %}) * of the items to apply the default styling and behavior. * * @example * ```html * <ng-template kendoMenuItemLinkTemplate let-item="item" let-index="index"> * <a [kendoMenuItemLink]="index">{{ item.text }}</a> * </ng-template> * ``` */ export class LinkDirective { itemsService; /** * Specifies the index of the Menu item. The input is mandatory. */ index; hostClasses = true; role = 'presentation'; tabindex = '-1'; get activeClass() { return this.item.opened; } item; constructor(itemsService) { this.itemsService = itemsService; } ngOnInit() { if (isDevMode() && !this.index) { throw new Error('The kendoMenuItemLink directive requires the item index to be set.'); } this.item = this.itemsService.get(this.index) || {}; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LinkDirective, deps: [{ token: i1.ItemsService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: LinkDirective, isStandalone: true, selector: "[kendoMenuItemLink]", inputs: { index: ["kendoMenuItemLink", "index"] }, host: { properties: { "class.k-link": "this.hostClasses", "class.k-menu-link": "this.hostClasses", "attr.role": "this.role", "attr.tabindex": "this.tabindex", "class.k-active": "this.activeClass" } }, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LinkDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoMenuItemLink]', standalone: true }] }], ctorParameters: () => [{ type: i1.ItemsService }], propDecorators: { index: [{ type: Input, args: ['kendoMenuItemLink'] }], hostClasses: [{ type: HostBinding, args: ['class.k-link'] }, { type: HostBinding, args: ['class.k-menu-link'] }], role: [{ type: HostBinding, args: ['attr.role'] }], tabindex: [{ type: HostBinding, args: ['attr.tabindex'] }], activeClass: [{ type: HostBinding, args: ['class.k-active'] }] } });