@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
84 lines (83 loc) • 3.67 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 kendoGridResizableContainer(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.grid && this.ctx.grid.wrapper) {
const containerElement = this.ctx.grid.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: "[kendoGridResizableContainer]", inputs: { lockedWidth: "lockedWidth", kendoGridResizableContainer: "kendoGridResizableContainer" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ResizableContainerDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridResizableContainer]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.ResizeService }, { type: i2.ContextService }]; }, propDecorators: { lockedWidth: [{
type: Input,
args: ['lockedWidth']
}], kendoGridResizableContainer: [{
type: Input
}] } });