igniteui-react-grids
Version:
Ignite UI React grid components.
375 lines (374 loc) • 12.6 kB
JavaScript
import { __extends, __values } from "tslib";
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";
var IgrGridColumnOptionsBase = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrGridColumnOptionsBase, _super);
function IgrGridColumnOptionsBase(props) {
var _this = _super.call(this, props) || this;
_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();
}
return _this;
}
IgrGridColumnOptionsBase.prototype.createImplementation = function () {
return null;
};
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "nativeElement", {
get: function () {
return this._implementation.nativeElement;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgrGridColumnOptionsBase._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igr" + name;
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
IgrGridColumnOptionsBase.prototype.onImplementationCreated = function () {
};
IgrGridColumnOptionsBase.prototype.componentDidMount = function () {
var e_1, _a;
this.mounted = true;
try {
for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) {
var p = _c.value;
if (isValidProp(this, p)) {
this[p] = this.props[p];
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
};
IgrGridColumnOptionsBase.prototype.shouldComponentUpdate = function (nextProps, nextState) {
var e_2, _a;
var mod = getModifiedProps(this.props, nextProps);
try {
for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) {
var p = _c.value;
if (isValidProp(this, p)) {
this[p] = mod[p];
}
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_2)
throw e_2.error;
}
}
return true;
};
IgrGridColumnOptionsBase.prototype.render = function () {
return null;
};
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "autoSize", {
/**
* Gets or sets the autoSize for which this AutoSizeOptions will apply.
*/
get: function () {
return this.i.ak;
},
set: function (v) {
this.i.ak = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "backgroundColor", {
/**
* Gets or sets the color to use for the background of the component.
*/
get: function () {
return brushToString(this.i.bo);
},
set: function (v) {
this.i.bo = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "baseTheme", {
/**
* Gets or sets the base built in theme to use for the component.
*/
get: function () {
return this.i.j;
},
set: function (v) {
this.i.j = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "actualBaseTheme", {
/**
* Gets the actual display baseTheme to use for the component.
*/
get: function () {
return this.i.i;
},
set: function (v) {
this.i.i = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "buttonDensity", {
/**
* Gets or sets the display Density to use for the buttons in the component.
*/
get: function () {
return this.i.buttonDensity;
},
set: function (v) {
this.i.buttonDensity = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "actualButtonDensity", {
/**
* Gets the actual display buttonDensity to use for the component.
*/
get: function () {
return this.i.p;
},
set: function (v) {
this.i.p = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "buttonTextStyle", {
/**
* Gets or sets the font to use for buttons.
*/
get: function () {
if (this.i.ab == null) {
return null;
}
return this.i.ab.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.ab = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "column", {
/**
* Gets or sets the column for which this ColumnOptions will apply.
*/
get: function () {
var r = this.i.column;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = IgrDataGridColumn._createFromInternal(r);
if (e) {
e._implementation = r;
}
r.externalObject = e;
}
return r.externalObject;
},
set: function (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;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "density", {
/**
* Gets or sets the display density to use for the component.
*/
get: function () {
return this.i.density;
},
set: function (v) {
this.i.density = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "actualDensity", {
/**
* Gets the actual display density to use for the component.
*/
get: function () {
return this.i.q;
},
set: function (v) {
this.i.q = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "labelTextStyle", {
/**
* Gets or sets the font to use for labels.
*/
get: function () {
if (this.i.ag == null) {
return null;
}
return this.i.ag.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.ag = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "textColor", {
/**
* Gets or sets the color to use for the text of the component.
*/
get: function () {
return brushToString(this.i.br);
},
set: function (v) {
this.i.br = stringToBrush(v);
},
enumerable: false,
configurable: true
});
IgrGridColumnOptionsBase.prototype.findByName = function (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;
};
Object.defineProperty(IgrGridColumnOptionsBase.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgrGridColumnOptionsBase.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgrGridColumnOptionsBase.prototype._styling = function (container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
var genericPrefix = "";
var typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("GridColumnOptionsBase");
var additionalPrefixes = [];
var prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
var 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);
}
var basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
var parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
var 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;
};
return IgrGridColumnOptionsBase;
}(React.Component));
export { IgrGridColumnOptionsBase };