UNPKG

@progress/kendo-angular-grid

Version:

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

49 lines (48 loc) 2.24 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Pipe } from '@angular/core'; import { getter } from '@progress/kendo-common'; import { isString, isNullOrEmptyString } from '../../utils'; import { IntlService } from '@progress/kendo-angular-intl'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-intl"; const FORMAT_REGEX = /\{\d+:?/; /** * @hidden */ export class FieldAccessorPipe { intlService; constructor(intlService) { this.intlService = intlService; } transform(dataItem, fieldName, format) { if (!isNullOrEmptyString(fieldName)) { const value = getter(fieldName)(dataItem); if (!isNullOrEmptyString(format)) { return this.formatValue(format, value); } return value; } return dataItem; } formatValue(format, value) { const intl = this.intlService; if (isString(format) && format.match(FORMAT_REGEX)) { return intl.format(format, value); } return intl.toString(value, format); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FieldAccessorPipe, deps: [{ token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: FieldAccessorPipe, isStandalone: true, name: "valueOf", pure: false }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FieldAccessorPipe, decorators: [{ type: Pipe, args: [{ // eslint-disable-next-line @angular-eslint/pipe-prefix name: 'valueOf', pure: false, standalone: true }] }], ctorParameters: function () { return [{ type: i1.IntlService }]; } });