igniteui-react-core
Version:
Ignite UI React Core.
384 lines (383 loc) • 12.8 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, Number_$type, runOn, delegateCombine, fromEn, fromEnum } from "./type";
import { Rect } from "./Rect";
import { Size } from "./Size";
import { ObservableCollection$1 } from "./ObservableCollection$1";
import { SizeDefinitionCollection } from "./SizeDefinitionCollection";
import { Dictionary$2 } from "./Dictionary$2";
import { GridLayoutSizeDefinition } from "./GridLayoutSizeDefinition";
import { GridLayoutLayoutInfo } from "./GridLayoutLayoutInfo";
import { List$1 } from "./List$1";
import { GridLayoutSizeInfo } from "./GridLayoutSizeInfo";
import { NativeUI } from "./NativeUI";
/**
* @hidden
*/
export let IGridLayoutView_$type = /*@__PURE__*/ new Type(null, 'IGridLayoutView');
/**
* @hidden
*/
export let GridLayoutView = /*@__PURE__*/ (() => {
class GridLayoutView extends Base {
constructor() {
super(...arguments);
this.a = null;
this._model = null;
}
get model() {
return this._model;
}
set model(a) {
this._model = a;
}
b(a, b) {
}
childrenCollectionChanged() {
if (this.a == null) {
return;
}
this.a.rootWrapper.removeChildren();
}
c(a, b) {
if ((a.getNativeElement)) {
a = a.getNativeElement();
}
let c = (a);
return new Size(1, c.offsetWidth, c.offsetHeight);
}
provideContainer(a) {
if (a == null) {
return;
}
this.a = a;
this.childrenCollectionChanged();
}
}
GridLayoutView.$t = /*@__PURE__*/ markType(GridLayoutView, 'GridLayoutView', Base.$, [IGridLayoutView_$type]);
return GridLayoutView;
})();
/**
* @hidden
*/
export let GridLayout = /*@__PURE__*/ (() => {
class GridLayout extends Base {
get e() {
return this.d;
}
get o() {
return this.n;
}
get h() {
return this.f;
}
get i() {
return this.g;
}
constructor() {
super();
this.n = null;
this.f = null;
this.g = null;
this.l = null;
this.k = null;
this.b = null;
this.q = 0;
this.p = 0;
this.a = null;
this.d = null;
this.j = false;
this.d = new GridLayoutView();
this.d.model = this;
this.f = new SizeDefinitionCollection();
this.g = new SizeDefinitionCollection();
this.n = new ObservableCollection$1(Base.$, 0);
this.l = new Dictionary$2(Base.$, Number_$type, 0);
this.k = new Dictionary$2(Base.$, Number_$type, 0);
let a = this.n;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.t));
let b = this.f;
b.collectionChanged = delegateCombine(b.collectionChanged, runOn(this, this.u));
let c = this.g;
c.collectionChanged = delegateCombine(c.collectionChanged, runOn(this, this.v));
}
v(a, b) {
this.ad();
}
u(a, b) {
this.ad();
}
t(a, b) {
if (b.newItems != null) {
for (let c of fromEn(b.newItems)) {
let d = 0;
let e = 0;
if (this.k.containsKey(c)) {
d = this.k.item(c);
}
if (this.l.containsKey(c)) {
e = this.l.item(c);
}
this.ag(c, e);
this.af(c, d);
}
}
if (b.oldItems != null) {
for (let f of fromEn(b.oldItems)) {
if (this.k.containsKey(f)) {
this.k.removeItem(f);
}
if (this.l.containsKey(f)) {
this.l.removeItem(f);
}
}
}
this.e.childrenCollectionChanged();
this.ad();
}
onSizeChanged(a, b) {
this.q = a;
this.p = b;
this.ad();
}
y() {
let a = new GridLayoutLayoutInfo();
a.h = this.g.count > 0 ? this.g.count : 1;
a.g = this.f.count > 0 ? this.f.count : 1;
a.b = false;
a.a = false;
let b = 0;
let c = 0;
for (let d of fromEnum(this.g)) {
switch (d.a) {
case 0: break;
case 2:
a.a = true;
c += d.b;
break;
case 1:
b += d.b;
break;
}
}
a.c = b;
a.e = c;
let e = 0;
let f = 0;
for (let g of fromEnum(this.f)) {
switch (g.a) {
case 0: break;
case 2:
a.b = true;
f += g.b;
break;
case 1:
e += g.b;
break;
}
}
a.d = e;
a.f = f;
this.b = a;
}
c(a) {
this.y();
let b = this.m();
let c = this.b.c;
let d = this.b.d;
let e = new Array(this.b.g);
let f = new Array(this.b.h);
let g = 0;
let h = 0;
for (let i = 0; i < this.b.h; i++) {
let j = this.g.count > 0 ? this.g._inner[i] : new GridLayoutSizeDefinition(1, 2, 1);
let k = 0;
switch (j.a) {
case 0:
for (let l = 0; l < this.b.g; l++) {
if (b.containsKey(i) && b.item(i).containsKey(l)) {
let m = b.item(i).item(l);
for (let n of fromEnum(m)) {
let o = NativeUI.as(n);
k = Math.max(k, o.height);
}
}
}
f[i] = k;
c = Math.max(0, c + k);
break;
case 2:
g += j.b;
break;
case 1:
f[i] = j.b;
break;
}
}
for (let p = 0; p < this.b.g; p++) {
let q = this.f.count > 0 ? this.f._inner[p] : new GridLayoutSizeDefinition(1, 2, 1);
let r = 0;
switch (q.a) {
case 0:
for (let s = 0; s < this.b.h; s++) {
if (b.containsKey(s) && b.item(s).containsKey(p)) {
let t = b.item(s).item(p);
for (let u of fromEnum(t)) {
let v = NativeUI.as(u);
r = Math.max(r, v.width);
}
}
}
e[p] = r;
d = Math.max(0, d + r);
break;
case 2:
h += q.b;
break;
case 1:
e[p] = q.b;
break;
}
}
let w = a.height - c;
for (let x = 0; x < this.b.h; x++) {
let y = this.g.count > 0 ? this.g._inner[x] : new GridLayoutSizeDefinition(1, 2, 1);
switch (y.a) {
case 0: break;
case 2:
f[x] = y.b / g * w;
break;
case 1: break;
}
}
let z = Math.max(0, a.width - d);
for (let aa = 0; aa < this.b.g; aa++) {
let ab = this.f.count > 0 ? this.f._inner[aa] : new GridLayoutSizeDefinition(1, 2, 1);
switch (ab.a) {
case 0: break;
case 2:
e[aa] = ab.b / h * z;
break;
case 1: break;
}
}
let ac = 0;
let ad = 0;
let ae = 0;
let af = 0;
let ag = new Array(this.b.h);
let ah = new Array(this.b.g);
for (let ai = 0; ai < this.b.h; ai++) {
let aj = this.g.count > 0 ? this.g._inner[ai] : new GridLayoutSizeDefinition(1, 2, 1);
ag[ai] = ae;
ae += f[ai];
ad += f[ai];
}
for (let ak = 0; ak < this.b.g; ak++) {
let al = this.f.count > 0 ? this.f._inner[ak] : new GridLayoutSizeDefinition(1, 2, 1);
ah[ak] = af;
af += e[ak];
ac += e[ak];
}
return ((() => {
let $ret = new GridLayoutSizeInfo();
$ret.e = new Size(1, ac, ad);
$ret.d = ag;
$ret.a = ah;
$ret.b = e;
$ret.c = f;
return $ret;
})());
}
ab() {
this.y();
let a = this.c(new Size(1, this.q, this.p));
for (let b of fromEnum(this.o)) {
let c = this.l.containsKey(b) ? this.l.item(b) : 0;
let d = this.k.containsKey(b) ? this.k.item(b) : 0;
let e = a.c[c];
let f = a.b[d];
let g = a.a[d];
let h = a.d[c];
NativeUI.m(b, new Rect(0, g, h, f, e));
}
this.j = false;
}
m() {
let a = new Dictionary$2(Number_$type, Dictionary$2.$.specialize(Number_$type, List$1.$.specialize(Base.$)), 0);
for (let b = 0; b < this.b.h; b++) {
a.addItem(b, new Dictionary$2(Number_$type, List$1.$.specialize(Base.$), 0));
for (let c = 0; c < this.b.g; c++) {
a.item(b).addItem(c, new List$1(Base.$, 0));
}
}
for (let d of fromEnum(this.o)) {
let e = this.s(d);
let f = this.r(d);
a.item(e).item(f).add1(d);
}
return a;
}
ad() {
if (!this.j) {
this.j = true;
this.a.enqueueAction(runOn(this, this.ab));
}
}
w(a) {
this.n.add1(a);
}
z(a, b) {
this.n.insert1(a, b);
}
ae(a) {
this.n.remove1(a);
}
x() {
this.n.clear();
}
af(a, b) {
if (this.k.containsKey(a)) {
this.k.item(a, b);
}
else {
this.k.addItem(a, b);
}
if (!this.l.containsKey(a)) {
this.ag(a, 0);
}
}
r(a) {
if (this.k.containsKey(a)) {
return this.k.item(a);
}
return 0;
}
ag(a, b) {
if (this.l.containsKey(a)) {
this.l.item(a, b);
}
else {
this.l.addItem(a, b);
}
if (!this.k.containsKey(a)) {
this.af(a, 0);
}
}
s(a) {
if (this.l.containsKey(a)) {
return this.l.item(a);
}
return 0;
}
ac(a) {
this.e.provideContainer(a);
}
}
GridLayout.$t = /*@__PURE__*/ markType(GridLayout, 'GridLayout');
return GridLayout;
})();