igniteui-react-core
Version:
Ignite UI React Core.
823 lines (822 loc) • 21.1 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, Type, markType } from "./type";
import { isNaN_ } from "./number";
import { stringEmpty, stringReplace, stringIsNullOrEmpty } from "./string";
/**
* @hidden
*/
export var IRenderer_$type = /*@__PURE__*/ new Type(null, 'IRenderer');
/**
* @hidden
*/
var FontInfo = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(FontInfo, _super);
function FontInfo() {
var _this = _super.call(this) || this;
_this.i = 0;
_this.n = null;
_this.o = null;
_this.p = null;
_this.d = 0;
_this.e = 0;
_this.k = null;
_this.l = null;
_this.m = null;
_this.f = NaN;
_this.g = NaN;
return _this;
}
FontInfo.prototype.w = function (a) {
if (isNaN_(this.f)) {
var b = FontUtil.getFontInfoFromString(a, this.fontString);
this.k = b.q;
this.d = b.f;
this.l = b.r;
this.n = b.t;
this.o = b.u;
this.p = b.v;
}
};
FontInfo.prototype.c = function () {
return isNaN_(this.f) && this.q == null && (this.fontString == null || this.fontString == "NaNpx/normal");
};
Object.defineProperty(FontInfo.prototype, "j", {
get: function () {
return this.i;
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "t", {
get: function () {
return this.n;
},
set: function (a) {
var b = this.n;
this.n = a;
if (b != this.n) {
this.x("FontStyle");
}
},
enumerable: false,
configurable: true
});
FontInfo.prototype.x = function (a) {
if (a != "FontString") {
this.m = null;
}
if (this.i < 100000) {
this.i++;
}
else {
this.i = 0;
}
};
Object.defineProperty(FontInfo.prototype, "u", {
get: function () {
return this.o;
},
set: function (a) {
var b = this.o;
this.o = a;
if (this.o != b) {
this.x("FontVariant");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "v", {
get: function () {
return this.p;
},
set: function (a) {
var b = this.p;
this.p = a;
if (this.p != b) {
this.x("FontWeight");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "f", {
get: function () {
return this.d;
},
set: function (a) {
var b = this.d;
this.d = a;
if (this.d != b) {
this.x("FontSize");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "g", {
get: function () {
return this.e;
},
set: function (a) {
var b = this.e;
this.e = a;
if (this.e != b) {
this.x("LineHeight");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "q", {
get: function () {
return this.k;
},
set: function (a) {
var b = this.k;
this.k = a;
if (this.k != b) {
this.x("FontFamily");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "r", {
get: function () {
return this.l;
},
set: function (a) {
var b = this.l;
this.l = a;
if (this.l != b) {
this.x("FontStretch");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FontInfo.prototype, "fontString", {
get: function () {
if (this.m == null) {
FontUtil.updateFontString(this);
}
return this.m;
},
set: function (a) {
var b = this.m;
this.m = a;
if (this.m != b) {
this.x("FontString");
}
},
enumerable: false,
configurable: true
});
FontInfo.prototype.a = function () {
var _this = this;
return ((function () {
var $ret = new FontInfo();
$ret.t = _this.t;
$ret.u = _this.u;
$ret.v = _this.v;
$ret.f = _this.f;
$ret.g = _this.g;
$ret.q = _this.q;
$ret.r = _this.r;
$ret.fontString = _this.fontString;
return $ret;
})());
};
FontInfo.prototype.h = function (a) {
if (a > 0) {
return this.f * a;
}
return this.f;
};
FontInfo.prototype.b = function (a) {
var b = this.a();
if (a > 0) {
b.f = a;
}
return b;
};
FontInfo.$t = markType(FontInfo, 'FontInfo');
return FontInfo;
}(Base));
export { FontInfo };
/**
* @hidden
*/
var FontUtil = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(FontUtil, _super);
function FontUtil() {
return _super !== null && _super.apply(this, arguments) || this;
}
FontUtil.getCurrentFontHeight = function (a, b) {
if (a == null) {
return 14;
}
var c = null;
if (b != null) {
c = b.fontString;
}
return a.getHeightForFontString(c, "M", true);
};
FontUtil.measureStringHeight = function (a, b, c) {
var d = a.getHeightForFontString(c.fontString, b, false);
return d;
};
FontUtil.measureStringWidth1 = function (a, b, c) {
c.aa();
c.ac(b);
var d = c.g(a);
c.z();
return d;
};
FontUtil.measureStringWidth = function (a, b, c) {
c.aa();
c.ad(b);
var d = c.g(a);
c.z();
return d;
};
FontUtil.getDefaultFont = function (a) {
if (FontUtil.a == null) {
FontUtil.a = FontUtil.getFontInfoFromString(a, "12px Verdana");
}
return FontUtil.a;
};
FontUtil.getFontSize = function (a) {
return a.f;
};
FontUtil.getFontWithNewFontSize = function (a, b) {
var c = a.a();
c.f = b;
c.fontString = b + "px " + a.q;
return c;
};
FontUtil.getFontInfoFromString = function (a, b) {
a.startCSSQuery();
a.setCssQueryFontString(b);
var c = a.getCssDefaultPropertyValue("", "font-style");
var d = a.getCssDefaultPropertyValue("", "font-variant");
var e = a.getCssDefaultPropertyValue("", "font-weight");
e = FontUtil.o(e);
var f = a.getCssDefaultPropertyValue("", "font-size");
var g = a.getCssDefaultPropertyValue("", "line-height");
var h = a.getCssDefaultPropertyValue("", "font-family");
a.endCSSQuery();
var i = new FontInfo();
var j = true;
b = "";
if (c.length > 0) {
if (!j) {
b += " ";
}
else {
j = false;
}
b += c;
}
if (d.length > 0) {
if (!j) {
b += " ";
}
else {
j = false;
}
b += d;
}
if (e.length > 0) {
if (!j) {
b += " ";
}
else {
j = false;
}
b += e;
}
if (f.length > 0) {
if (!j) {
b += " ";
}
else {
j = false;
}
b += f;
}
if (g.length > 0) {
if (!j) {
b += "/";
}
else {
j = false;
}
b += g;
}
if (h.length > 0) {
if (!j) {
b += " ";
}
else {
j = false;
}
b += h;
}
var k = new FontInfo();
k.q = h;
k.f = parseFloat(f);
k.r = "Normal";
k.t = c;
k.u = d;
k.v = e;
k.fontString = b;
return k;
};
FontUtil.getFontForClass = function (a, b) {
var c = stringEmpty();
a.startCSSQuery();
var d = a.getCssDefaultPropertyValue(b, "font-style");
var e = a.getCssDefaultPropertyValue(b, "font-variant");
var f = a.getCssDefaultPropertyValue(b, "font-weight");
f = FontUtil.o(f);
var g = a.getCssDefaultPropertyValue(b, "font-size");
var h = a.getCssDefaultPropertyValue(b, "line-height");
var i = a.getCssDefaultPropertyValue(b, "font-family");
a.endCSSQuery();
var j = true;
if (d.length > 0) {
if (!j) {
c += " ";
}
else {
j = false;
}
c += d;
}
if (e.length > 0) {
if (!j) {
c += " ";
}
else {
j = false;
}
c += e;
}
if (f.length > 0) {
if (!j) {
c += " ";
}
else {
j = false;
}
c += f;
}
if (g.length > 0) {
if (!j) {
c += " ";
}
else {
j = false;
}
c += g;
}
if (h.length > 0) {
if (!j) {
c += "/";
}
else {
j = false;
}
c += h;
}
if (i.length > 0) {
if (!j) {
c += " ";
}
else {
j = false;
}
c += i;
}
var k = new FontInfo();
k.q = i;
k.f = parseFloat(g);
k.r = "Normal";
k.t = d;
k.u = e;
k.v = f;
k.fontString = c;
return k;
};
FontUtil.getFont = function (a) {
return FontUtil.getFontForClass(a, "");
};
FontUtil.updateFontString = function (a) {
var b = stringEmpty();
var c = a.t;
var d = a.u;
var e = a.v;
var f = a.f.toString();
var g = "normal";
var h = a.q;
var i = true;
if (c != null && c.length > 0) {
if (!i) {
b += " ";
}
else {
i = false;
}
b += c;
}
if (d != null && d.length > 0) {
if (!i) {
b += " ";
}
else {
i = false;
}
b += d;
}
if (e != null && e.length > 0) {
if (!i) {
b += " ";
}
else {
i = false;
}
b += e;
}
if (f.length > 0) {
if (!i) {
b += " ";
}
else {
i = false;
}
b += f + "px";
}
if (g != null && g.length > 0) {
if (!i) {
b += "/";
}
else {
i = false;
}
b += g;
}
if (h != null && h.length > 0) {
if (!i) {
b += " ";
}
else {
i = false;
}
b += h;
}
a.fontString = b;
};
FontUtil.getFontInfo = function (a, b, c) {
if (c == null) {
var d = new FontInfo();
a.startCSSQuery();
var e = a.getCssDefaultPropertyValue("", "font-style");
var f = a.getCssDefaultPropertyValue("", "font-variant");
var g = a.getCssDefaultPropertyValue("", "font-weight");
g = FontUtil.o(g);
var h = a.getCssDefaultPropertyValue("", "font-size");
var i = a.getCssDefaultPropertyValue("", "line-height");
var j = a.getCssDefaultPropertyValue("", "font-family");
d.q = stringReplace(j, "'", "");
d.t = FontUtil.p(e);
d.v = FontUtil.p(g.toString());
d.u = f;
d.g = parseFloat(i);
d.f = parseFloat(h);
a.endCSSQuery();
return d;
}
return c;
};
FontUtil.p = function (a) {
if (stringIsNullOrEmpty(a)) {
return stringEmpty();
}
var b = a.substr(0, 1).toUpperCase();
if (a.length > 1) {
b += a.substr(1);
}
return b;
};
FontUtil.toFontInfo = function (a, b) {
if (b == null) {
return null;
}
return FontUtil.getFontInfoFromString(a, b);
};
FontUtil.interpolateFont = function (a, b, c, d) {
if (c == null) {
c = d;
}
if (d == null) {
d = c;
}
if (c == null && d == null) {
return;
}
if (b > 0.5) {
a.q = d.q;
a.r = d.r;
a.t = d.t;
a.u = d.u;
a.v = d.v;
a.g = d.g;
a.f = d.f;
}
else {
a.q = c.q;
a.r = c.r;
a.t = c.t;
a.u = c.u;
a.v = c.v;
a.g = c.g;
a.f = c.f;
}
if (!isNaN_(c.f) && !isNaN_(d.f)) {
a.f = c.f + (d.f - c.f) * b;
}
FontUtil.updateFontString(a);
};
FontUtil.charsEqual = function (a, b, c, d) {
return Base.equalsStatic(a.charAt(b), c[d]);
};
FontUtil.o = function (a) {
switch (a) {
case "400":
a = "normal";
break;
case "700":
case "800":
a = "bold";
break;
}
return a;
};
FontUtil.$t = markType(FontUtil, 'FontUtil');
FontUtil.a = null;
return FontUtil;
}(Base));
export { FontUtil };
/**
* @hidden
*/
var RenderingContext = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(RenderingContext, _super);
function RenderingContext(a, b) {
var _this = _super.call(this) || this;
_this.c = null;
_this.e = false;
_this.c = a;
if (_this.c != null) {
_this.c.h$d = b;
}
return _this;
}
RenderingContext.prototype.h = function () {
if (this.c == null) {
return null;
}
return this.c.h$e();
};
Object.defineProperty(RenderingContext.prototype, "d", {
get: function () {
if (this.c == null) {
return false;
}
return true;
},
enumerable: false,
configurable: true
});
RenderingContext.prototype.w = function (a) {
if (this.c == null) {
return;
}
this.c.h$t(a);
};
RenderingContext.prototype.t = function (a) {
if (this.c == null) {
return;
}
this.c.h$q(a);
};
RenderingContext.prototype.r = function (a) {
if (this.c == null) {
return;
}
this.c.h$o(a);
};
RenderingContext.prototype.x = function (a) {
if (this.c == null) {
return;
}
this.c.h$u(a);
};
RenderingContext.prototype.y = function (a, b, c) {
if (this.c == null) {
return;
}
this.c.h$v(a, b, c);
};
RenderingContext.prototype.u = function (a) {
if (this.c == null) {
return;
}
this.c.h$r(a);
};
RenderingContext.prototype.v = function (a) {
if (this.c == null) {
return;
}
this.c.h$s(a);
};
RenderingContext.prototype.q = function (a, b) {
if (this.c == null) {
return;
}
this.c.h$n(a, b);
};
RenderingContext.prototype.k = function (a) {
if (this.c == null) {
return;
}
this.c.h$h(a);
};
RenderingContext.prototype.s = function (a) {
if (this.c == null) {
return;
}
this.c.h$p(a);
};
RenderingContext.prototype.aa = function () {
if (this.c == null) {
return;
}
this.c.h$x();
};
RenderingContext.prototype.z = function () {
if (this.c == null) {
return;
}
this.c.h$w();
};
RenderingContext.prototype.af = function (a) {
if (this.c == null) {
return;
}
this.c.h$ac(a);
};
RenderingContext.prototype.ab = function (a, b) {
if (this.c == null) {
return;
}
this.c.h$y(a, b);
};
RenderingContext.prototype.ag = function (a, b) {
if (this.c == null) {
return;
}
this.c.h$ad(a, b);
};
RenderingContext.prototype.l = function (a, b, c, d) {
if (this.c == null) {
return;
}
this.c.h$i(a, b, c, d);
};
RenderingContext.prototype.o = function (a, b, c, d, e, f, g, h, i, j) {
if (this.c == null) {
return;
}
this.c.h$l(a, b, c, d, e, f, g, h, i, j);
};
RenderingContext.prototype.n = function (a, b, c, d, e, f) {
if (this.c == null) {
return;
}
this.c.h$k(a, b, c, d, e, f);
};
RenderingContext.prototype.a = function (a, b) {
if (this.c == null) {
return null;
}
return this.c.h$a(a, b);
};
RenderingContext.prototype.i = function () {
if (this.c == null) {
return null;
}
return this.c.h$f();
};
RenderingContext.prototype.b = function () {
if (this.c == null) {
return null;
}
return this.c.h$b();
};
RenderingContext.prototype.ac = function (a) {
if (this.c == null) {
return;
}
this.c.h$z(a);
};
RenderingContext.prototype.ad = function (a) {
if (this.c == null) {
return;
}
this.c.h$aa(a);
};
RenderingContext.prototype.g = function (a) {
if (this.c == null) {
return NaN;
}
return this.c.h$c(a);
};
RenderingContext.prototype.ah = function (a, b, c) {
if (this.c == null) {
return null;
}
var d = this.c.h$b();
var e = 0;
if (d == null) {
d = this.c.h$f();
}
else {
e = d.j;
}
var f = a.an(d, e);
if (f != null) {
a.ah = f.a;
return f;
}
var g = this.c.h$ae(a.al, b, c);
a.am(d, e, g);
a.ah = g.a;
return g;
};
RenderingContext.prototype.f = function (a) {
if (this.c == null) {
return NaN;
}
var b = this.c.h$b();
var c = 0;
if (b == null) {
b = this.c.h$f();
}
else {
c = b.j;
}
var d = a.an(b, c);
if (d != null) {
return d.c;
}
var e = this.c.h$ae(a.al, NaN, true);
a.am(b, c, e);
return e.c;
};
RenderingContext.prototype.ae = function (a) {
if (this.c == null) {
return;
}
this.c.h$ab(a);
};
RenderingContext.prototype.j = function (a, b) {
if (this.c == null || b == null) {
return;
}
this.c.h$g(a, b);
};
RenderingContext.prototype.p = function (a, b, c, d) {
if (this.c == null) {
return;
}
this.c.h$m(a, b, c, d);
};
RenderingContext.prototype.m = function () {
if (this.c == null) {
return;
}
this.c.h$j();
};
RenderingContext.$t = markType(RenderingContext, 'RenderingContext');
return RenderingContext;
}(Base));
export { RenderingContext };