UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

218 lines (217 loc) 6.76 kB
import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { DataSourceSummaryOperand_$type } from "igniteui-react-core"; import { IgrFormatSummaryTextEventArgs } from "./igr-format-summary-text-event-args"; import { IgrProvideCalculatorEventArgs } from "igniteui-react-core"; import { ColumnSummaryDescription as ColumnSummaryDescription_internal } from "./ColumnSummaryDescription"; import { ensureEnum, ensureBool, arrayFindByName } from "igniteui-react-core"; /** * Represents a summary that is applied to a datasource. Changes to this object are not observed or expected after it is initially assigned to a collection. */ export class IgrColumnSummaryDescription { createImplementation() { return new ColumnSummaryDescription_internal(0); } get nativeElement() { return this._implementation.nativeElement; } /** * @hidden */ get i() { return this._implementation; } onImplementationCreated() { } constructor() { this.mounted = false; this._formatText = null; this._formatText_wrapped = null; this._provideCalculator = null; this._provideCalculator_wrapped = null; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } _provideImplementation(i) { this._implementation = i; this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } get field() { return this.i.ah; } set field(v) { this.i.ah = v; } get operand() { return this.i.i; } set operand(v) { this.i.i = ensureEnum(DataSourceSummaryOperand_$type, v); } /** * Gets or sets the name to use when displaying the calculator name. */ get calculatorDisplayName() { return this.i.ae; } set calculatorDisplayName(v) { this.i.ae = v; } /** * Gets or sets the display name for the summary. */ get displayName() { return this.i.ag; } set displayName(v) { this.i.ag = v; } /** * Gets or sets the format string for the summary value. */ get valueFormat() { return this.i.ai; } set valueFormat(v) { this.i.ai = v; } /** * Gets or sets whether the summary value should be displayed. */ get shouldDisplay() { return this.i.t; } set shouldDisplay(v) { this.i.t = ensureBool(v); } /** * Gets or sets the format specifiers to use with the ValueFormat string. */ get valueFormatSpecifiers() { return this.i.d; } set valueFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.d = v; } /** * Gets or sets the display format for the summary when in list display mode. */ get displayFormat() { return this.i.af; } set displayFormat(v) { this.i.af = v; } /** * Gets or sets the format specifiers to use with the DisplayFormat string. */ get displayFormatSpecifiers() { return this.i.c; } set displayFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.c = v; } /** * Gets or sets an INTL.DateTimeFormat or INTL.NumericFormat to use to format the value. */ get formatOverride() { return this.i.y; } set formatOverride(v) { this.i.y = v; } /** * Gets or sets the maximum fraction digits. If a format is specificied this value is ignored. */ get maxFractionDigits() { return this.i.w; } set maxFractionDigits(v) { this.i.w = +v; } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.valueFormatSpecifiers != null && arrayFindByName(this.valueFormatSpecifiers, name)) { return arrayFindByName(this.valueFormatSpecifiers, name); } if (this.displayFormatSpecifiers != null && arrayFindByName(this.displayFormatSpecifiers, name)) { return arrayFindByName(this.displayFormatSpecifiers, name); } return null; } equals(other) { let iv = this.i.equals(other); return (iv); } /** * Called when the value is being formatted. */ get formatText() { return this._formatText; } set formatText(ev) { if (this._formatText_wrapped !== null) { this.i.formatText = delegateRemove(this.i.formatText, this._formatText_wrapped); this._formatText_wrapped = null; this._formatText = null; } this._formatText = ev; this._formatText_wrapped = (o, e) => { let outerArgs = new IgrFormatSummaryTextEventArgs(); outerArgs._provideImplementation(e); if (this.beforeFormatText) { this.beforeFormatText(this, outerArgs); } if (this._formatText) { this._formatText(this, outerArgs); } }; this.i.formatText = delegateCombine(this.i.formatText, this._formatText_wrapped); ; } /** * Called when the summary calculator is required. */ get provideCalculator() { return this._provideCalculator; } set provideCalculator(ev) { if (this._provideCalculator_wrapped !== null) { this.i.provideCalculator = delegateRemove(this.i.provideCalculator, this._provideCalculator_wrapped); this._provideCalculator_wrapped = null; this._provideCalculator = null; } this._provideCalculator = ev; this._provideCalculator_wrapped = (o, e) => { let outerArgs = new IgrProvideCalculatorEventArgs(); outerArgs._provideImplementation(e); if (this.beforeProvideCalculator) { this.beforeProvideCalculator(this, outerArgs); } if (this._provideCalculator) { this._provideCalculator(this, outerArgs); } }; this.i.provideCalculator = delegateCombine(this.i.provideCalculator, this._provideCalculator_wrapped); ; } }