@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
175 lines (174 loc) • 6.54 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* 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 { Component, 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 dateOperators = localizeOperators({
"filterEqOperator": "eq",
"filterNotEqOperator": "neq",
"filterAfterOrEqualOperator": "gte",
"filterAfterOperator": "gt",
"filterBeforeOrEqualOperator": "lte",
"filterBeforeOperator": "lt",
"filterIsNullOperator": "isnull",
"filterIsNotNullOperator": "isnotnull"
});
/**
* @hidden
*/
export class DateFilterComponent extends BaseFilterCellComponent {
ctx;
/**
* The column with which the filter is associated.
* @type {ColumnComponent}
*/
column;
/**
* The default filter operator. Defaults to `contains`.
* @type {string}
* @default 'gte'
*/
operator = "gte";
/**
* The current filter for the associated column field.
* @readonly
* @type {FilterDescriptor}
*/
get currentFilter() {
return this.filterByField(this.column.field);
}
/**
* Specifies the date format that is used when the component is not focused.
* By default, the `column.format` value is used (if set).
*/
set format(value) {
this._format = value;
}
/**
* Specifies the date format that is used when the component is not focused.
* By default, the `column.format` value is used (if set).
*
* @readonly
* @type {string}
*/
get format() {
return !isNullOrEmptyString(this._format) ? this._format : this.columnFormat;
}
/**
* Specifies the smallest value that is valid.
* @type {Date}
*/
min;
/**
* Specifies the greatest value that is valid.
* @type {Date}
*/
max;
/**
* Defines the descriptions of the format sections in the input field.
* [See example](slug:placeholders_datepicker#toc-format-sections-description).
*/
formatPlaceholder;
/**
* Specifies the hint that the component displays when its value is `null`.
* [See example](slug:placeholders_datepicker#toc-text-hints).
*/
placeholder;
/**
* Defines the active view that the calendar initially renders.
* By default, the active view is `month`.
* You have to set `activeView` within the `topView`-`bottomView` range.
* @default 'month'
*/
activeView = "month";
/**
* Defines the bottommost calendar view, to which the user can navigate.
* @default 'month'
*/
bottomView = "month";
/**
* Defines the topmost calendar view, to which the user can navigate.
* @default 'century'
*/
topView = "century";
/**
* Determines whether to display a week number column in the `month` view of the Calendar.
* @default false
*/
weekNumber = false;
/**
* 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) : "d";
}
_format;
subscription;
constructor(filterService, ctx) {
super(filterService);
this.ctx = ctx;
this.defaultOperators = dateOperators(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 = dateOperators(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: DateFilterComponent, deps: [{ token: i1.FilterService }, { token: i2.ContextService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: DateFilterComponent, selector: "kendo-grid-date-filter-base", inputs: { column: "column", operator: "operator", format: "format", min: "min", max: "max", formatPlaceholder: "formatPlaceholder", placeholder: "placeholder", activeView: "activeView", bottomView: "bottomView", topView: "topView", weekNumber: "weekNumber" }, usesInheritance: true, ngImport: i0, template: ``, isInline: true });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DateFilterComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-grid-date-filter-base',
template: ``
}]
}], ctorParameters: function () { return [{ type: i1.FilterService }, { type: i2.ContextService }]; }, propDecorators: { column: [{
type: Input
}], operator: [{
type: Input
}], format: [{
type: Input
}], min: [{
type: Input
}], max: [{
type: Input
}], formatPlaceholder: [{
type: Input
}], placeholder: [{
type: Input
}], activeView: [{
type: Input
}], bottomView: [{
type: Input
}], topView: [{
type: Input
}], weekNumber: [{
type: Input
}] } });