igniteui-react-grids
Version:
Ignite UI React grid components.
484 lines (483 loc) • 18.6 kB
JavaScript
import { __extends, __values } from "tslib";
import * as React from 'react';
import { delegateCombine, delegateRemove } from "igniteui-react-core";
import { IgrGridConditionalStylePropertyCollection } from "./igr-grid-conditional-style-property-collection";
import { IgrPropertyUpdatedEventArgs } from "igniteui-react-core";
import { IgrGridConditionFilterStringErrorsParsingEventArgs } from "./igr-grid-condition-filter-string-errors-parsing-event-args";
import { GridConditionalStyle } from "./GridConditionalStyle";
import { TypeRegistrar } from "igniteui-react-core";
import { ContentChildrenManager } from "igniteui-react-core";
import { CollectionAdapter, NamePatcher, getModifiedProps, isValidProp, ensureBool, toSpinal, initializePropertiesFromCss } from "igniteui-react-core";
import { GridConditionalStyleProperty } from "./GridConditionalStyleProperty";
import { NotifyCollectionChangedAction } from "igniteui-react-core";
var IgrGridConditionalStyle = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrGridConditionalStyle, _super);
function IgrGridConditionalStyle(props) {
var _this = _super.call(this, props) || this;
_this.mounted = false;
_this._properties = null;
_this.__p = null;
_this._hasUserValues = new Set();
_this._stylingContainer = null;
_this._stylingParent = null;
_this._inStyling = false;
_this._propertyUpdated = null;
_this._propertyUpdated_wrapped = null;
_this._filterStringErrorsParsing = null;
_this._filterStringErrorsParsing_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();
}
return _this;
}
IgrGridConditionalStyle.prototype.createImplementation = function () {
return new GridConditionalStyle();
};
Object.defineProperty(IgrGridConditionalStyle.prototype, "nativeElement", {
get: function () {
return this._implementation.nativeElement;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgrGridConditionalStyle._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);
};
IgrGridConditionalStyle.prototype.onImplementationCreated = function () {
};
IgrGridConditionalStyle.prototype._initializeAdapters = function () {
var _this = this;
if (!this._contentChildrenManager) {
var resolveNested_1 = (function (props, propName, nestedPropName) {
var _a;
var prop = props[propName];
if (Array.isArray(prop)) {
return prop.map(function (x) {
var _a;
return (_a = x[nestedPropName]) !== null && _a !== void 0 ? _a : resolveNested_1(x.props, propName, nestedPropName);
}).join("_");
}
else if (prop) {
return (_a = prop.props[nestedPropName]) !== null && _a !== void 0 ? _a : resolveNested_1(prop.props, propName, nestedPropName);
}
else {
return props[nestedPropName];
}
});
this._contentChildrenManager = new ContentChildrenManager(function (ch) {
var key = ch.key || ch.props.name;
if (!key) {
var type = (ch.type);
var instance = new type;
var name_1 = instance.i.$type.name;
switch (name_1) {
default: return undefined;
}
}
return key;
}, function (ch) {
var key = ch.key || ch.props.name;
if (!key) {
var type = (ch.type);
var instance = new type;
var name_2 = instance.i.$type.name;
switch (name_2) {
default: return undefined;
}
}
return key;
}, function () {
if (_this._updateContentChildren) {
_this._updateContentChildren();
}
else if (_this._updateAdapters) {
_this._updateAdapters();
}
});
}
this._propertiesAdapter = new CollectionAdapter(this.contentProperties, this.i.properties, this.actualProperties, function (c) { return c.i; }, function (i) {
if (_this._initializeElement) {
_this._initializeElement(i);
}
}, function (i) {
if (_this._destroyElement) {
_this._destroyElement(i);
}
});
if (_super.prototype["_initializeAdapters"]) {
_super.prototype["_initializeAdapters"].call(this);
}
};
IgrGridConditionalStyle.prototype._updateAdapters = function () {
if (_super.prototype["_updateAdapters"]) {
_super.prototype["_updateAdapters"].call(this);
}
var contentChildrenActual = this._contentChildrenManager.contentChildrenActual;
this.contentProperties.length = 0;
for (var i = 0; i < contentChildrenActual.length; i++) {
if ((GridConditionalStyleProperty.$type).isAssignableFrom(contentChildrenActual[i].i.$type)) {
this.contentProperties.push(contentChildrenActual[i]);
}
}
if (this._propertiesAdapter != null) {
this._propertiesAdapter.notifyContentChanged();
}
};
IgrGridConditionalStyle.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;
}
}
};
IgrGridConditionalStyle.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;
};
IgrGridConditionalStyle.prototype.render = function () {
var children = this._contentChildrenManager.getChildren(this.props.children);
var div = React.createElement("div", {
children: children
});
return div;
};
Object.defineProperty(IgrGridConditionalStyle.prototype, "isCompound", {
get: function () {
return this.i.s;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "styleKey", {
get: function () {
return this.i.ak;
},
set: function (v) {
this.i.ak = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "isTransitionInEnabled", {
get: function () {
return this.i.w;
},
set: function (v) {
this.i.w = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "actualProperties", {
get: function () {
if (!this._actualProperties) {
this._actualProperties = [];
}
return this._actualProperties;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "contentProperties", {
get: function () {
if (!this._contentProperties) {
this._contentProperties = [];
}
return this._contentProperties;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "properties", {
get: function () {
var _this = this;
if (this._properties === null) {
var coll = new IgrGridConditionalStylePropertyCollection();
var inner = coll._innerColl;
this._properties = coll;
inner.addListener(function (sender, e) {
switch (e.action) {
case NotifyCollectionChangedAction.Add:
_this._propertiesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0));
break;
case NotifyCollectionChangedAction.Remove:
_this._propertiesAdapter.removeManualItemAt(e.oldStartingIndex);
break;
case NotifyCollectionChangedAction.Replace:
_this._propertiesAdapter.removeManualItemAt(e.oldStartingIndex);
_this._propertiesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0));
break;
case NotifyCollectionChangedAction.Reset:
_this._propertiesAdapter.clearManualItems();
break;
}
});
;
}
return this._properties;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "conditionString", {
get: function () {
return this.i.ae;
},
set: function (v) {
this.i.ae = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "condition", {
get: function () {
return this.i.e;
},
set: function (v) {
this.i.e = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "isFieldMinimumNeeded", {
get: function () {
return this.i.u;
},
set: function (v) {
this.i.u = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "isFieldMaximumNeeded", {
get: function () {
return this.i.t;
},
set: function (v) {
this.i.t = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "isFieldSumNeeded", {
get: function () {
return this.i.v;
},
set: function (v) {
this.i.v = ensureBool(v);
},
enumerable: false,
configurable: true
});
IgrGridConditionalStyle.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.properties != null && this.properties.findByName && this.properties.findByName(name)) {
return this.properties.findByName(name);
}
return null;
};
Object.defineProperty(IgrGridConditionalStyle.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgrGridConditionalStyle.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgrGridConditionalStyle.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("GridConditionalStyle");
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._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
};
IgrGridConditionalStyle.prototype.requiresGlobalValues = function () {
var iv = this.i.x();
return (iv);
};
IgrGridConditionalStyle.prototype.actualNeedsFieldMinimum = function () {
var iv = this.i.q();
return (iv);
};
IgrGridConditionalStyle.prototype.actualNeedsFieldMaximum = function () {
var iv = this.i.p();
return (iv);
};
IgrGridConditionalStyle.prototype.actualNeedsFieldSum = function () {
var iv = this.i.r();
return (iv);
};
Object.defineProperty(IgrGridConditionalStyle.prototype, "propertyUpdated", {
get: function () {
return this._propertyUpdated;
},
set: function (ev) {
var _this = this;
if (this._propertyUpdated_wrapped !== null) {
this.i.propertyUpdated = delegateRemove(this.i.propertyUpdated, this._propertyUpdated_wrapped);
this._propertyUpdated_wrapped = null;
this._propertyUpdated = null;
}
this._propertyUpdated = ev;
this._propertyUpdated_wrapped = function (o, e) {
var outerArgs = new IgrPropertyUpdatedEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforePropertyUpdated) {
_this.beforePropertyUpdated(_this, outerArgs);
}
if (_this._propertyUpdated) {
_this._propertyUpdated(_this, outerArgs);
}
};
this.i.propertyUpdated = delegateCombine(this.i.propertyUpdated, this._propertyUpdated_wrapped);
;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridConditionalStyle.prototype, "filterStringErrorsParsing", {
get: function () {
return this._filterStringErrorsParsing;
},
set: function (ev) {
var _this = this;
if (this._filterStringErrorsParsing_wrapped !== null) {
this.i.filterStringErrorsParsing = delegateRemove(this.i.filterStringErrorsParsing, this._filterStringErrorsParsing_wrapped);
this._filterStringErrorsParsing_wrapped = null;
this._filterStringErrorsParsing = null;
}
this._filterStringErrorsParsing = ev;
this._filterStringErrorsParsing_wrapped = function (o, e) {
var outerArgs = new IgrGridConditionFilterStringErrorsParsingEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeFilterStringErrorsParsing) {
_this.beforeFilterStringErrorsParsing(_this, outerArgs);
}
if (_this._filterStringErrorsParsing) {
_this._filterStringErrorsParsing(_this, outerArgs);
}
};
this.i.filterStringErrorsParsing = delegateCombine(this.i.filterStringErrorsParsing, this._filterStringErrorsParsing_wrapped);
;
},
enumerable: false,
configurable: true
});
return IgrGridConditionalStyle;
}(React.Component));
export { IgrGridConditionalStyle };