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