UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

455 lines (454 loc) 13.4 kB
import * as React from 'react'; import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { DataSourceSchemaPropertyType_$type } from "igniteui-react-core"; import { IgrOperatorSelectorValueChangedEventArgs } from "./igr-operator-selector-value-changed-event-args"; import { IgrOperatorSelectorOpeningEventArgs } from "./igr-operator-selector-opening-event-args"; import { IgrOperatorSelectorClosingEventArgs } from "./igr-operator-selector-closing-event-args"; import { ComparisonOperatorSelector } from "./ComparisonOperatorSelector"; import { TypeRegistrar } from "igniteui-react-core"; import { NamePatcher, getModifiedProps, isValidProp, ensureEnum, brushToString, stringToBrush, toSpinal, initializePropertiesFromCss } from "igniteui-react-core"; /** * A dropdown selector for choosing which comparison operator to use. */ export class IgrDataGridComparisonOperatorSelector extends React.Component { createImplementation() { return new ComparisonOperatorSelector(); } get nativeElement() { return this._implementation.nativeElement; } /** * @hidden */ get i() { return this._implementation; } /** * @hidden */ static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igr" + name; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } onImplementationCreated() { } constructor(props) { super(props); this.mounted = false; this.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; this._valueChanged = null; this._valueChanged_wrapped = null; this._opening = null; this._opening_wrapped = null; this._opened = null; this._opened_wrapped = null; this._closing = null; this._closing_wrapped = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } componentDidMount() { this.mounted = true; for (const p of Object.keys(this.props)) { if (isValidProp(this, p)) { this[p] = this.props[p]; } } } shouldComponentUpdate(nextProps, nextState) { const mod = getModifiedProps(this.props, nextProps); for (const p of Object.keys(mod)) { if (isValidProp(this, p)) { this[p] = mod[p]; } } return true; } render() { return null; } /** * Gets or sets the value of the selector. */ get value() { return this.i.b; } set value(v) { this.i.b = v; } /** * Gets the ID for the custom filter that is selected. Value must be 'Custom' for this property to be valid. */ get customFilterID() { return this.i.ae; } set customFilterID(v) { this.i.ae = v; } /** * Gets the index for the custom filter that is selected. Value must be 'Custom' for this property to be valid. */ get customFilterIndex() { return this.i.x; } set customFilterIndex(v) { this.i.x = +v; } /** * Gets or sets the data type. Used to determine what operators are available. */ get dataType() { return this.i.d; } set dataType(v) { this.i.d = ensureEnum(DataSourceSchemaPropertyType_$type, v); } get maxHeight() { return this.i.z; } set maxHeight(v) { this.i.z = +v; } /** * Gets or sets the text color. */ get textColor() { return brushToString(this.i.eq); } set textColor(v) { this.i.eq = stringToBrush(v); } /** * Gets or sets the background color. */ get background() { return brushToString(this.i.ep); } set background(v) { this.i.ep = stringToBrush(v); } get operatorCaptionTrue() { return this.i.dd; } get operatorCaptionFalse() { return this.i.ck; } get operatorCaptionEquals() { return this.i.cj; } get operatorCaptionNotEquals() { return this.i.cz; } get operatorCaptionLessThan() { return this.i.cr; } get operatorCaptionLessThanOrEqual() { return this.i.cs; } get operatorCaptionGreaterThan() { return this.i.cl; } get operatorCaptionGreaterThanOrEqual() { return this.i.cm; } get operatorCaptionTop() { return this.i.db; } get operatorCaptionBottom() { return this.i.cb; } get operatorCaptionTopPercentile() { return this.i.dc; } get operatorCaptionBottomPercentile() { return this.i.cc; } get operatorCaptionToday() { return this.i.c9; } get operatorCaptionTomorrow() { return this.i.da; } get operatorCaptionYesterday() { return this.i.dg; } get operatorCaptionThisWeek() { return this.i.c7; } get operatorCaptionNextWeek() { return this.i.cw; } get operatorCaptionLastWeek() { return this.i.cp; } get operatorCaptionThisMonth() { return this.i.c5; } get operatorCaptionNextMonth() { return this.i.cu; } get operatorCaptionLastMonth() { return this.i.cn; } get operatorCaptionThisQuarter() { return this.i.c6; } get operatorCaptionNextQuarter() { return this.i.cv; } get operatorCaptionLastQuarter() { return this.i.co; } get operatorCaptionThisYear() { return this.i.c8; } get operatorCaptionNextYear() { return this.i.cx; } get operatorCaptionLastYear() { return this.i.cq; } get operatorCaptionYearToDate() { return this.i.df; } get operatorCaptionQ1() { return this.i.c0; } get operatorCaptionQ2() { return this.i.c1; } get operatorCaptionQ3() { return this.i.c2; } get operatorCaptionQ4() { return this.i.c3; } get operatorCaptionMonth() { return this.i.ct; } get operatorCaptionYear() { return this.i.de; } get operatorCaptionStartsWith() { return this.i.c4; } get operatorCaptionDoesNotStartWith() { return this.i.cg; } get operatorCaptionEndsWith() { return this.i.ci; } get operatorCaptionDoesNotEndWith() { return this.i.cf; } get operatorCaptionContains() { return this.i.cd; } get operatorCaptionDoesNotContain() { return this.i.ce; } get operatorCaptionEmpty() { return this.i.ch; } get operatorCaptionNotEmpty() { return this.i.cy; } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; } get hasUserValues() { return this._hasUserValues; } __m(propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } } _styling(container, component, parent) { if (this._inStyling) { return; } this._inStyling = true; this._stylingContainer = container; this._stylingParent = component; let genericPrefix = ""; let typeName = this.i.$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("DataGridComparisonOperatorSelector"); let additionalPrefixes = []; let prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); let b = this.i.$type.baseType; while (b && b.name != "Object" && b.name != "Base" && b.name != "Control" && b.Name != "DependencyObject" && b.Name != "FrameworkElement") { typeName = b.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } let basePrefix = toSpinal(typeName); additionalPrefixes.push(basePrefix + "-"); b = b.baseType; } if (parent) { let parentTypeName = parent.i.$type.name; if (parentTypeName.indexOf("Xam") === 0) { parentTypeName = parentTypeName.substring(3); } let parentPrefix = toSpinal(parentTypeName); additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-"); additionalPrefixes.push(parentPrefix + "-" + prefix + "-"); } initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes); if (this._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; } provideContainer(container) { this.i.ej(container); } dispose() { this.i.ea(); } getDropdownHeight() { let iv = this.i.y(); return (iv); } toggle() { this.i.em(); } close() { this.i.d8(); } addCustomOperator(name, icon, id, index) { this.i.d1(name, icon, id, index); } clearCustomOperators() { this.i.d7(); } selectCustomFilter(id, index) { this.i.ek(id, index); } get valueChanged() { return this._valueChanged; } set valueChanged(ev) { if (this._valueChanged_wrapped !== null) { this.i.valueChanged = delegateRemove(this.i.valueChanged, this._valueChanged_wrapped); this._valueChanged_wrapped = null; this._valueChanged = null; } this._valueChanged = ev; this._valueChanged_wrapped = (o, e) => { let outerArgs = new IgrOperatorSelectorValueChangedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeValueChanged) { this.beforeValueChanged(this, outerArgs); } if (this._valueChanged) { this._valueChanged(this, outerArgs); } }; this.i.valueChanged = delegateCombine(this.i.valueChanged, this._valueChanged_wrapped); ; } get opening() { return this._opening; } set opening(ev) { if (this._opening_wrapped !== null) { this.i.opening = delegateRemove(this.i.opening, this._opening_wrapped); this._opening_wrapped = null; this._opening = null; } this._opening = ev; this._opening_wrapped = (o, e) => { let outerArgs = new IgrOperatorSelectorOpeningEventArgs(); outerArgs._provideImplementation(e); if (this.beforeOpening) { this.beforeOpening(this, outerArgs); } if (this._opening) { this._opening(this, outerArgs); } }; this.i.opening = delegateCombine(this.i.opening, this._opening_wrapped); ; } get opened() { return this._opened; } set opened(ev) { if (this._opened_wrapped !== null) { this.i.opened = delegateRemove(this.i.opened, this._opened_wrapped); this._opened_wrapped = null; this._opened = null; } this._opened = ev; this._opened_wrapped = (o, e) => { let outerArgs = new IgrOperatorSelectorOpeningEventArgs(); outerArgs._provideImplementation(e); if (this.beforeOpened) { this.beforeOpened(this, outerArgs); } if (this._opened) { this._opened(this, outerArgs); } }; this.i.opened = delegateCombine(this.i.opened, this._opened_wrapped); ; } get closing() { return this._closing; } set closing(ev) { if (this._closing_wrapped !== null) { this.i.closing = delegateRemove(this.i.closing, this._closing_wrapped); this._closing_wrapped = null; this._closing = null; } this._closing = ev; this._closing_wrapped = (o, e) => { let outerArgs = new IgrOperatorSelectorClosingEventArgs(); outerArgs._provideImplementation(e); if (this.beforeClosing) { this.beforeClosing(this, outerArgs); } if (this._closing) { this._closing(this, outerArgs); } }; this.i.closing = delegateCombine(this.i.closing, this._closing_wrapped); ; } }