igniteui-react-grids
Version:
Ignite UI React grid components.
299 lines (298 loc) • 10.6 kB
JavaScript
import { __assign, __extends, __values } from "tslib";
import * as React from 'react';
import { IgrPivotGrid } from "./igr-pivot-grid";
import { PivotDataSelector } from "./PivotDataSelector";
import { TypeRegistrar } from "igniteui-react-core";
import { ReactRenderer, PortalManager } from "igniteui-react-core";
import { NamePatcher, getModifiedProps, isValidProp, ensureBool, toSpinal, initializePropertiesFromCss } from "igniteui-react-core";
var IgrPivotDataSelector = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrPivotDataSelector, _super);
function IgrPivotDataSelector(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._getMainRef = _this._getMainRef.bind(_this);
_this._implementation = _this.createImplementation();
_this._portalManager = new PortalManager("templates", function () {
if (_this.mounted) {
_this.setState({});
}
});
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
_this._renderer = new ReactRenderer(_this._implementation.nativeElement, document, false, null, _this._portalManager);
}
_this._implementation.externalObject = _this;
_this.onImplementationCreated();
if (_this._initializeAdapters) {
_this._initializeAdapters();
}
return _this;
}
IgrPivotDataSelector.prototype.createImplementation = function () {
return new PivotDataSelector();
};
Object.defineProperty(IgrPivotDataSelector.prototype, "nativeElement", {
get: function () {
return this._implementation.nativeElement;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPivotDataSelector.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgrPivotDataSelector._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);
};
IgrPivotDataSelector.prototype.onImplementationCreated = function () {
};
IgrPivotDataSelector.prototype.componentDidMount = function () {
var e_1, _a;
this.i.nativeElement = this._elRef;
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;
}
}
};
IgrPivotDataSelector.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;
};
IgrPivotDataSelector.prototype.render = function () {
var _this = this;
var nativePropsName = Object.keys(this.props).filter(function (prop) { return !isValidProp(_this, prop) && prop !== "originalRef" && prop !== "className"; });
var nativeProps = {};
nativePropsName.forEach(function (propName) {
nativeProps[propName] = _this.props[propName];
});
var propChildren = this.props.children;
var children = [];
React.Children.forEach(propChildren, function (ch) {
children.push(React.cloneElement(ch));
});
this._portalManager.onRender(children);
var style = {};
if (this.props.style) {
style = this.props.style;
}
var div = React.createElement("igc-pivot-data-selector", __assign(__assign({}, nativeProps), { ref: this._getMainRef, id: this.props.id, class: this.props.className, style: style, children: children }));
return div;
};
IgrPivotDataSelector.prototype._getMainRef = function (ref) {
this._elRef = ref;
};
Object.defineProperty(IgrPivotDataSelector.prototype, "columnsExpanded", {
get: function () {
return this.i.d;
},
set: function (v) {
this.i.d = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPivotDataSelector.prototype, "rowsExpanded", {
get: function () {
return this.i.f;
},
set: function (v) {
this.i.f = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPivotDataSelector.prototype, "filtersExpanded", {
get: function () {
return this.i.e;
},
set: function (v) {
this.i.e = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPivotDataSelector.prototype, "valuesExpanded", {
get: function () {
return this.i.g;
},
set: function (v) {
this.i.g = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPivotDataSelector.prototype, "grid", {
/**
* Sets the grid.
*/
get: function () {
var r = this.i.a;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgrPivotGrid({});
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(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.a = null : this.i.a = v.i;
},
enumerable: false,
configurable: true
});
IgrPivotDataSelector.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.grid && this.grid.name && this.grid.name == name) {
return this.grid;
}
return null;
};
Object.defineProperty(IgrPivotDataSelector.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgrPivotDataSelector.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgrPivotDataSelector.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("PivotDataSelector");
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.grid && this.grid._styling) {
this.grid._styling(container, component, this);
}
if (this._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
};
IgrPivotDataSelector.prototype.setNativeElement = function (element) {
this.i.setNativeElement(element);
};
return IgrPivotDataSelector;
}(React.Component));
export { IgrPivotDataSelector };