UNPKG

@progress/kendo-angular-treeview

Version:
69 lines (68 loc) 3.02 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { ChangeDetectorRef, Directive, Input } from '@angular/core'; import { TreeViewComponent } from './treeview.component'; import * as i0 from "@angular/core"; import * as i1 from "./treeview.component"; /** * A directive which manages the disabled in-memory state of the TreeView node * ([see example]({% slug disabledstate_treeview %})). */ export class DisableDirective { treeView; cdr; /** * @hidden */ set isDisabled(value) { this.treeView.isDisabled = value; } /** * Defines the item key that will be stored in the `disabledKeys` collection. */ disableKey; /** * Defines the collection that will store the disabled keys. */ disabledKeys = []; constructor(treeView, cdr) { this.treeView = treeView; this.cdr = cdr; this.treeView.isDisabled = (dataItem, index) => (this.disabledKeys.indexOf(this.itemKey({ dataItem, index })) > -1); } ngOnChanges(changes = {}) { const { disabledKeys } = changes; if (disabledKeys && !disabledKeys.firstChange) { this.cdr.markForCheck(); } } itemKey(e) { if (!this.disableKey) { return e.index; } if (typeof this.disableKey === "string") { return e.dataItem[this.disableKey]; } if (typeof this.disableKey === "function") { return this.disableKey(e); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DisableDirective, deps: [{ token: i1.TreeViewComponent }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: DisableDirective, isStandalone: true, selector: "[kendoTreeViewDisable]", inputs: { isDisabled: "isDisabled", disableKey: ["kendoTreeViewDisable", "disableKey"], disabledKeys: "disabledKeys" }, usesOnChanges: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DisableDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoTreeViewDisable]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.TreeViewComponent }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { isDisabled: [{ type: Input }], disableKey: [{ type: Input, args: ["kendoTreeViewDisable"] }], disabledKeys: [{ type: Input }] } });