@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.
84 lines (83 loc) • 3.71 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 { Directive, ElementRef, Input, Renderer2 } from '@angular/core';
import { ResizeService } from "./resize.service";
import { ContextService } from './../common/provider.service';
import * as i0 from "@angular/core";
import * as i1 from "./resize.service";
import * as i2 from "./../common/provider.service";
/**
* @hidden
*/
export class ResizableContainerDirective {
el;
renderer;
resizeService;
ctx;
_lockedWidth;
set lockedWidth(value) {
this._lockedWidth = value;
if (this.enabled) {
this.attachResize();
this.resize();
}
}
set kendoTreeListResizableContainer(enabled) {
const refresh = enabled !== this.enabled;
this.enabled = enabled;
if (refresh) {
this.attachResize();
this.resize();
}
}
enabled = false;
resizeSubscription;
constructor(el, renderer, resizeService, ctx) {
this.el = el;
this.renderer = renderer;
this.resizeService = resizeService;
this.ctx = ctx;
}
ngOnDestroy() {
if (this.resizeSubscription) {
this.resizeSubscription.unsubscribe();
}
}
attachResize() {
if (this.resizeSubscription && !this.enabled) {
this.resizeSubscription.unsubscribe();
this.resizeSubscription = null;
}
if (!this.resizeSubscription && this.enabled) {
this.resizeSubscription = this.resizeService.changes.subscribe(this.resize.bind(this));
}
}
resize() {
if (this.ctx.treelist && this.ctx.treelist.wrapper) {
const containerElement = this.ctx.treelist.wrapper.nativeElement;
const width = Math.max(containerElement.clientWidth - this._lockedWidth, 0);
if (this.enabled && width > 0) {
this.renderer.setStyle(this.el.nativeElement, "width", width + "px");
}
else {
this.renderer.setStyle(this.el.nativeElement, "width", "");
}
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ResizableContainerDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.ResizeService }, { token: i2.ContextService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ResizableContainerDirective, isStandalone: true, selector: "[kendoTreeListResizableContainer]", inputs: { lockedWidth: "lockedWidth", kendoTreeListResizableContainer: "kendoTreeListResizableContainer" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ResizableContainerDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoTreeListResizableContainer]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.ResizeService }, { type: i2.ContextService }]; }, propDecorators: { lockedWidth: [{
type: Input,
args: ['lockedWidth']
}], kendoTreeListResizableContainer: [{
type: Input
}] } });