UNPKG

@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.

145 lines (144 loc) 5.39 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 } from '@angular/core'; import { ColumnComponent } from '../columns/column.component'; import { FilterService } from './filter.service'; import { BaseFilterCellComponent, localizeOperators } from './base-filter-cell.component'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { isNullOrEmptyString, extractFormat } from '../utils'; import { toJSON } from './operators/filter-operator.base'; import * as i0 from "@angular/core"; import * as i1 from "./filter.service"; import * as i2 from "@progress/kendo-angular-l10n"; const numericOperators = localizeOperators({ "filterEqOperator": "eq", "filterNotEqOperator": "neq", "filterGteOperator": "gte", "filterGtOperator": "gt", "filterLteOperator": "lte", "filterLtOperator": "lt", "filterIsNullOperator": "isnull", "filterIsNotNullOperator": "isnotnull" }); /** * Represents a base numeric filter component for the TreeList. */ export class NumericFilterComponent extends BaseFilterCellComponent { localization; /** * The column with which the filter is associated. * @type {ColumnComponent} */ column; /** * The default filter operator. * @type {string} * @default 'eq' */ operator = "eq"; /** * Specifies the value that is used to increment or decrement the component value. * @type {number} * @default 1 */ step = 1; /** * Specifies the smallest value that is valid. * @type {number} */ min; /** * Specifies the greatest value that is valid. * @type {number} */ max; /** * Specifies whether the **Up** and **Down** spin buttons will be rendered. * @type {boolean} * @default true */ spinners = true; /** * Specifies the number precision applied to the component value when it is focused. * If the user enters a number with a greater precision than is currently configured, the component value is rounded. * @type {number} */ decimals; /** * Specifies the number format used when the component is not focused. * By default, the `column.format` value is used (if set). * @type {string} */ get format() { return !isNullOrEmptyString(this._format) ? this._format : this.columnFormat; } set format(value) { this._format = value; } /** * The current filter for the associated column field. * @readonly * @type {FilterDescriptor} */ get currentFilter() { return this.filterByField(this.column.field); } /** * The current filter operator for the associated column field. * @readonly * @type {string} */ get currentOperator() { return this.currentFilter ? this.currentFilter.operator : this.operator; } get columnFormat() { return this.column && !isNullOrEmptyString(this.column.format) ? extractFormat(this.column.format) : "n2"; } _format; subscription; constructor(filterService, localization) { super(filterService); this.localization = localization; this.defaultOperators = numericOperators(this.localization); } ngOnInit() { this.subscription = this.localization.changes.subscribe(this.localizationChange.bind(this)); } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } super.ngOnDestroy(); } localizationChange() { this.defaultOperators = numericOperators(this.localization); if (this.operatorList.length) { this.operators = toJSON(this.operatorList.toArray()); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NumericFilterComponent, deps: [{ token: i1.FilterService }, { token: i2.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: NumericFilterComponent, inputs: { column: "column", operator: "operator", step: "step", min: "min", max: "max", spinners: "spinners", decimals: "decimals", format: "format" }, usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NumericFilterComponent, decorators: [{ type: Directive, args: [{}] }], ctorParameters: function () { return [{ type: i1.FilterService }, { type: i2.LocalizationService }]; }, propDecorators: { column: [{ type: Input }], operator: [{ type: Input }], step: [{ type: Input }], min: [{ type: Input }], max: [{ type: Input }], spinners: [{ type: Input }], decimals: [{ type: Input }], format: [{ type: Input }] } });