igniteui-react-core
Version:
Ignite UI React Core.
135 lines (134 loc) • 4.92 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { Base, Number_$type, String_$type, markType } from "./type";
import { DescriptionPath } from "./DescriptionPath";
import { List$1 } from "./List$1";
import { DescriptionPathSegment } from "./DescriptionPathSegment";
import { DescriptionPathIndexer } from "./DescriptionPathIndexer";
import { stringContains, stringReplace } from "./string";
import { stringSplit } from "./stringExtended";
/**
* @hidden
*/
var DescriptionPathParser = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(DescriptionPathParser, _super);
function DescriptionPathParser() {
return _super !== null && _super.apply(this, arguments) || this;
}
DescriptionPathParser.prototype.parse = function (a) {
if (a == null) {
return null;
}
if (stringContains(a, "|")) {
var b = a.split('|');
var c = new List$1(DescriptionPath.$, 0);
for (var e = 0; e < b.length; e++) {
var d = b[e];
var f = this.parse(d.trim());
c.add(f);
}
var g = this.b(c);
return g;
}
var h = new List$1(DescriptionPathSegment.$, 0);
this.d(h, a);
var i = new DescriptionPath();
i.rootSegments = [h.toArray()];
return i;
};
DescriptionPathParser.prototype.d = function (a, b) {
var _this = this;
if (b == null) {
return;
}
var c = stringSplit(b, ['.', '['], 0);
var _loop_1 = function (d) {
var e = c[d];
var f = c.length > 1;
var g = false;
var h = new List$1(Number_$type, 0);
var i = new List$1(String_$type, 0);
var j = null;
if (stringContains(e, "]")) {
g = true;
e = stringReplace(e, "]", "");
var k = e.split(',');
for (var l = 0; l < k.length; l++) {
var m = k[l];
if (stringContains(m, "as")) {
var n = m.indexOf("as");
var o = m.substr(0, n).trim();
var p = m.substr(n + 2).trim();
if (o.trim() == "*") {
h.add(-1);
i.add(p);
}
else {
h.add(parseInt(o));
i.add(p);
}
j = p;
e = o;
}
else {
h.add(parseInt(m.trim()));
i.add(null);
}
}
}
if (g) {
if (a.count > 0) {
var q = a._inner[a.count - 1];
q.indexers = this_1.a(h, i);
}
else {
a.add(((function () {
var $ret = new DescriptionPathSegment();
$ret.indexers = _this.a(h, i);
return $ret;
})()));
}
}
else {
a.add(((function () {
var $ret = new DescriptionPathSegment();
$ret.elementName = e.trim();
return $ret;
})()));
}
};
var this_1 = this;
for (var d = 0; d < c.length; d++) {
_loop_1(d);
}
};
DescriptionPathParser.prototype.a = function (a, b) {
var c = new Array(a.count);
for (var d = 0; d < a.count; d++) {
var e = new DescriptionPathIndexer();
if (a._inner[d] == -1) {
e.a = true;
e.c = b._inner[d];
}
c[d] = e;
}
return c;
};
DescriptionPathParser.prototype.b = function (a) {
var b = new DescriptionPath();
b.rootSegments = new Array(a.count);
for (var c = 0; c < a.count; c++) {
b.rootSegments[c] = a._inner[c].rootSegments[0];
b.operator = 1;
}
return b;
};
DescriptionPathParser.$t = markType(DescriptionPathParser, 'DescriptionPathParser');
return DescriptionPathParser;
}(Base));
export { DescriptionPathParser };