UNPKG

@progress/kendo-angular-grid

Version:

Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.

146 lines (145 loc) 5.2 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ // eslint-disable no-access-missing-member 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 { isNullOrEmptyString, extractFormat } from '../utils'; import { toJSON } from './operators/filter-operator.base'; import { ContextService } from '../common/provider.service'; import * as i0 from "@angular/core"; import * as i1 from "./filter.service"; import * as i2 from "../common/provider.service"; const numericOperators = localizeOperators({ "filterEqOperator": "eq", "filterNotEqOperator": "neq", "filterGteOperator": "gte", "filterGtOperator": "gt", "filterLteOperator": "lte", "filterLtOperator": "lt", "filterIsNullOperator": "isnull", "filterIsNotNullOperator": "isnotnull" }); /** * @hidden * Represents a base numeric filter component. */ export class NumericFilterComponent extends BaseFilterCellComponent { ctx; /** * Specifies the column for this filter. * @type {ColumnComponent} */ column; /** * Sets the default filter operator. * @type {string} * @default 'eq' */ operator = "eq"; /** * Sets the value used to increment or decrement the component value. * @type {numeric} * @default 1 */ step = 1; /** * Sets the smallest valid value. * @type {number} */ min; /** * Sets the greatest valid value. * @type {number} */ max; /** * When `true`, shows the **Up** and **Down** spin buttons. * @type {boolean} * @default true */ spinners = true; /** * Sets the number precision for the value when focused. * If the user enters a number with greater precision, the value is rounded. * @type {number} */ decimals; /** * Gets the number format used when the component is not focused. * Uses `column.format` if set. */ get format() { return !isNullOrEmptyString(this._format) ? this._format : this.columnFormat; } set format(value) { this._format = value; } /** * Gets the current filter for the column field. * @readonly * @type {FilterDescriptor} */ get currentFilter() { return this.filterByField(this.column.field); } /** * Gets the current filter operator for the 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, ctx) { super(filterService); this.ctx = ctx; this.defaultOperators = numericOperators(this.ctx.localization); } ngOnInit() { this.subscription = this.ctx.localization.changes.subscribe(this.localizationChange.bind(this)); } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } super.ngOnDestroy(); } localizationChange() { this.defaultOperators = numericOperators(this.ctx.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.ContextService }], 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.ContextService }]; }, 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 }] } });