igniteui-react-core
Version:
Ignite UI React Core.
540 lines (539 loc) • 17.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 { __extends, __read, __spreadArray, __values } from "tslib";
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 var IGridLayoutView_$type = /*@__PURE__*/ new Type(null, 'IGridLayoutView');
/**
* @hidden
*/
var GridLayoutView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridLayoutView, _super);
function GridLayoutView() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this.a = null;
_this._model = null;
return _this;
}
Object.defineProperty(GridLayoutView.prototype, "model", {
get: function () {
return this._model;
},
set: function (a) {
this._model = a;
},
enumerable: false,
configurable: true
});
GridLayoutView.prototype.b = function (a, b) {
};
GridLayoutView.prototype.childrenCollectionChanged = function () {
if (this.a == null) {
return;
}
this.a.rootWrapper.removeChildren();
};
GridLayoutView.prototype.c = function (a, b) {
if ((a.getNativeElement)) {
a = a.getNativeElement();
}
var c = (a);
return new Size(1, c.offsetWidth, c.offsetHeight);
};
GridLayoutView.prototype.provideContainer = function (a) {
if (a == null) {
return;
}
this.a = a;
this.childrenCollectionChanged();
};
GridLayoutView.$t = markType(GridLayoutView, 'GridLayoutView', Base.$, [IGridLayoutView_$type]);
return GridLayoutView;
}(Base));
export { GridLayoutView };
/**
* @hidden
*/
var GridLayout = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridLayout, _super);
function GridLayout() {
var _this = _super.call(this) || this;
_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);
var a = _this.n;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.t));
var b = _this.f;
b.collectionChanged = delegateCombine(b.collectionChanged, runOn(_this, _this.u));
var c = _this.g;
c.collectionChanged = delegateCombine(c.collectionChanged, runOn(_this, _this.v));
return _this;
}
Object.defineProperty(GridLayout.prototype, "e", {
get: function () {
return this.d;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridLayout.prototype, "o", {
get: function () {
return this.n;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridLayout.prototype, "h", {
get: function () {
return this.f;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridLayout.prototype, "i", {
get: function () {
return this.g;
},
enumerable: false,
configurable: true
});
GridLayout.prototype.v = function (a, b) {
this.ad();
};
GridLayout.prototype.u = function (a, b) {
this.ad();
};
GridLayout.prototype.t = function (a, b) {
var e_1, _a, e_2, _b;
if (b.newItems != null) {
try {
for (var _c = __values(fromEn(b.newItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
var c = _d.value;
var d = 0;
var 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);
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
if (b.oldItems != null) {
try {
for (var _e = __values(fromEn(b.oldItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
var f = _f.value;
if (this.k.containsKey(f)) {
this.k.removeItem(f);
}
if (this.l.containsKey(f)) {
this.l.removeItem(f);
}
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
this.e.childrenCollectionChanged();
this.ad();
};
GridLayout.prototype.onSizeChanged = function (a, b) {
this.q = a;
this.p = b;
this.ad();
};
GridLayout.prototype.y = function () {
var e_3, _a, e_4, _b;
var 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;
var b = 0;
var c = 0;
try {
for (var _c = __values(fromEnum(this.g)), _d = _c.next(); !_d.done; _d = _c.next()) {
var d = _d.value;
switch (d.a) {
case 0: break;
case 2:
a.a = true;
c += d.b;
break;
case 1:
b += d.b;
break;
}
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_3)
throw e_3.error;
}
}
a.c = b;
a.e = c;
var e = 0;
var f = 0;
try {
for (var _e = __values(fromEnum(this.f)), _f = _e.next(); !_f.done; _f = _e.next()) {
var g = _f.value;
switch (g.a) {
case 0: break;
case 2:
a.b = true;
f += g.b;
break;
case 1:
e += g.b;
break;
}
}
}
catch (e_4_1) {
e_4 = { error: e_4_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_4)
throw e_4.error;
}
}
a.d = e;
a.f = f;
this.b = a;
};
GridLayout.prototype.c = function (a) {
var e_5, _a, e_6, _b;
this.y();
var b = this.m();
var c = this.b.c;
var d = this.b.d;
var e = new Array(this.b.g);
var f = new Array(this.b.h);
var g = 0;
var h = 0;
for (var i = 0; i < this.b.h; i++) {
var j = this.g.count > 0 ? this.g._inner[i] : new GridLayoutSizeDefinition(1, 2, 1);
var k = 0;
switch (j.a) {
case 0:
for (var l = 0; l < this.b.g; l++) {
if (b.containsKey(i) && b.item(i).containsKey(l)) {
var m = b.item(i).item(l);
try {
for (var _c = (e_5 = void 0, __values(fromEnum(m))), _d = _c.next(); !_d.done; _d = _c.next()) {
var n = _d.value;
var o = NativeUI.as(n);
k = Math.max(k, o.height);
}
}
catch (e_5_1) {
e_5 = { error: e_5_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_5)
throw e_5.error;
}
}
}
}
f[i] = k;
c = Math.max(0, c + k);
break;
case 2:
g += j.b;
break;
case 1:
f[i] = j.b;
break;
}
}
for (var p = 0; p < this.b.g; p++) {
var q = this.f.count > 0 ? this.f._inner[p] : new GridLayoutSizeDefinition(1, 2, 1);
var r = 0;
switch (q.a) {
case 0:
for (var s = 0; s < this.b.h; s++) {
if (b.containsKey(s) && b.item(s).containsKey(p)) {
var t = b.item(s).item(p);
try {
for (var _e = (e_6 = void 0, __values(fromEnum(t))), _f = _e.next(); !_f.done; _f = _e.next()) {
var u = _f.value;
var v = NativeUI.as(u);
r = Math.max(r, v.width);
}
}
catch (e_6_1) {
e_6 = { error: e_6_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_6)
throw e_6.error;
}
}
}
}
e[p] = r;
d = Math.max(0, d + r);
break;
case 2:
h += q.b;
break;
case 1:
e[p] = q.b;
break;
}
}
var w = a.height - c;
for (var x = 0; x < this.b.h; x++) {
var 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;
}
}
var z = Math.max(0, a.width - d);
for (var aa = 0; aa < this.b.g; aa++) {
var 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;
}
}
var ac = 0;
var ad = 0;
var ae = 0;
var af = 0;
var ag = new Array(this.b.h);
var ah = new Array(this.b.g);
for (var ai = 0; ai < this.b.h; ai++) {
var aj = this.g.count > 0 ? this.g._inner[ai] : new GridLayoutSizeDefinition(1, 2, 1);
ag[ai] = ae;
ae += f[ai];
ad += f[ai];
}
for (var ak = 0; ak < this.b.g; ak++) {
var al = this.f.count > 0 ? this.f._inner[ak] : new GridLayoutSizeDefinition(1, 2, 1);
ah[ak] = af;
af += e[ak];
ac += e[ak];
}
return ((function () {
var $ret = new GridLayoutSizeInfo();
$ret.e = new Size(1, ac, ad);
$ret.d = ag;
$ret.a = ah;
$ret.b = e;
$ret.c = f;
return $ret;
})());
};
GridLayout.prototype.ab = function () {
var e_7, _a;
this.y();
var a = this.c(new Size(1, this.q, this.p));
try {
for (var _b = __values(fromEnum(this.o)), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
var c = this.l.containsKey(b) ? this.l.item(b) : 0;
var d = this.k.containsKey(b) ? this.k.item(b) : 0;
var e = a.c[c];
var f = a.b[d];
var g = a.a[d];
var h = a.d[c];
NativeUI.m(b, new Rect(0, g, h, f, e));
}
}
catch (e_7_1) {
e_7 = { error: e_7_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_7)
throw e_7.error;
}
}
this.j = false;
};
GridLayout.prototype.m = function () {
var e_8, _a;
var a = new Dictionary$2(Number_$type, Dictionary$2.$.specialize(Number_$type, List$1.$.specialize(Base.$)), 0);
for (var b = 0; b < this.b.h; b++) {
a.addItem(b, new Dictionary$2(Number_$type, List$1.$.specialize(Base.$), 0));
for (var c = 0; c < this.b.g; c++) {
a.item(b).addItem(c, new List$1(Base.$, 0));
}
}
try {
for (var _b = __values(fromEnum(this.o)), _c = _b.next(); !_c.done; _c = _b.next()) {
var d = _c.value;
var e = this.s(d);
var f = this.r(d);
a.item(e).item(f).add1(d);
}
}
catch (e_8_1) {
e_8 = { error: e_8_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_8)
throw e_8.error;
}
}
return a;
};
GridLayout.prototype.ad = function () {
if (!this.j) {
this.j = true;
this.a.enqueueAction(runOn(this, this.ab));
}
};
GridLayout.prototype.w = function (a) {
this.n.add1(a);
};
GridLayout.prototype.z = function (a, b) {
this.n.insert1(a, b);
};
GridLayout.prototype.ae = function (a) {
this.n.remove1(a);
};
GridLayout.prototype.x = function () {
this.n.clear();
};
GridLayout.prototype.af = function (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);
}
};
GridLayout.prototype.r = function (a) {
if (this.k.containsKey(a)) {
return this.k.item(a);
}
return 0;
};
GridLayout.prototype.ag = function (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);
}
};
GridLayout.prototype.s = function (a) {
if (this.l.containsKey(a)) {
return this.l.item(a);
}
return 0;
};
GridLayout.prototype.ac = function (a) {
this.e.provideContainer(a);
};
GridLayout.$t = markType(GridLayout, 'GridLayout');
return GridLayout;
}(Base));
export { GridLayout };