UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

276 lines (275 loc) 8.32 kB
import * as React from 'react'; import { BaseControlTheme_$type } from "igniteui-react-core"; import { ControlDisplayDensity_$type } from "igniteui-react-core"; import { IgrDataGridColumn } from "./igr-data-grid-column"; import { TypeRegistrar } from "igniteui-react-core"; import { NamePatcher, getModifiedProps, isValidProp, ensureBool, brushToString, stringToBrush, ensureEnum, toSpinal, initializePropertiesFromCss } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; export class IgrGridColumnOptionsBase extends React.Component { createImplementation() { return null; } 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; 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 autoSize for which this AutoSizeOptions will apply. */ get autoSize() { return this.i.ak; } set autoSize(v) { this.i.ak = ensureBool(v); } /** * Gets or sets the color to use for the background of the component. */ get backgroundColor() { return brushToString(this.i.bo); } set backgroundColor(v) { this.i.bo = stringToBrush(v); } /** * Gets or sets the base built in theme to use for the component. */ get baseTheme() { return this.i.j; } set baseTheme(v) { this.i.j = ensureEnum(BaseControlTheme_$type, v); } /** * Gets the actual display baseTheme to use for the component. */ get actualBaseTheme() { return this.i.i; } set actualBaseTheme(v) { this.i.i = ensureEnum(BaseControlTheme_$type, v); } /** * Gets or sets the display Density to use for the buttons in the component. */ get buttonDensity() { return this.i.buttonDensity; } set buttonDensity(v) { this.i.buttonDensity = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets the actual display buttonDensity to use for the component. */ get actualButtonDensity() { return this.i.p; } set actualButtonDensity(v) { this.i.p = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets or sets the font to use for buttons. */ get buttonTextStyle() { if (this.i.ab == null) { return null; } return this.i.ab.fontString; } set buttonTextStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.ab = fi; } /** * Gets or sets the column for which this ColumnOptions will apply. */ get column() { const r = this.i.column; if (r == null) { return null; } if (!r.externalObject) { let e = IgrDataGridColumn._createFromInternal(r); if (e) { e._implementation = r; } r.externalObject = e; } return r.externalObject; } set column(v) { if (v != null && this._stylingContainer && v._styling) v._styling(this._stylingContainer, this, this); v == null ? this.i.column = null : this.i.column = v.i; } /** * Gets or sets the display density to use for the component. */ get density() { return this.i.density; } set density(v) { this.i.density = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets the actual display density to use for the component. */ get actualDensity() { return this.i.q; } set actualDensity(v) { this.i.q = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets or sets the font to use for labels. */ get labelTextStyle() { if (this.i.ag == null) { return null; } return this.i.ag.fontString; } set labelTextStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.ag = fi; } /** * Gets or sets the color to use for the text of the component. */ get textColor() { return brushToString(this.i.br); } set textColor(v) { this.i.br = stringToBrush(v); } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.column && this.column.name && this.column.name == name) { return this.column; } 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("GridColumnOptionsBase"); 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.column && this.column._styling) { this.column._styling(container, component, this); } if (this._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; } }