UNPKG

igniteui-react-core

Version:
822 lines (821 loc) 28.6 kB
/* 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, INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateCombine, enumGetBox, typeCast, delegateRemove, String_$type, markType } from "./type"; import { IDataSourceLocalDataProvider_$type } from "./IDataSourceLocalDataProvider"; import { FlatDataProviderJoinType_$type } from "./FlatDataProviderJoinType"; import { FlatDataProviderJoinCollisionType_$type } from "./FlatDataProviderJoinCollisionType"; import { DataSourceLocalDataProvider } from "./DataSourceLocalDataProvider"; import { VirtualDataSource } from "./VirtualDataSource"; import { List$1 } from "./List$1"; import { Dictionary$2 } from "./Dictionary$2"; import { HashSet$1 } from "./HashSet$1"; import { DataSourceSchemaPropertyType_$type } from "./DataSourceSchemaPropertyType"; import { IDataSourceUpdateNotifier_$type } from "./IDataSourceUpdateNotifier"; /** * @hidden */ var FlatDataProvider = /** @class */ /*@__PURE__*/ (function (_super) { __extends(FlatDataProvider, _super); function FlatDataProvider() { var _this = _super.call(this) || this; _this.n = new DataSourceLocalDataProvider(); _this.k = null; _this.j = null; _this.p = false; _this.z = null; _this.aa = null; _this.h = 1; _this.e = 0; _this.ab = null; _this.w = null; _this.q = false; _this.schemaChanged = null; _this.propertyChanged = null; _this.o = false; _this.a = null; _this.r = true; var a = _this.n; a.schemaChanged = delegateCombine(a.schemaChanged, runOn(_this, _this.ap)); _this.n.sortDescriptions.n(runOn(_this, _this.ay)); _this.n.groupDescriptions.n(runOn(_this, _this.aw)); _this.n.summaryDescriptions.n(runOn(_this, _this.az)); _this.n.filterExpressions.n(runOn(_this, _this.av)); return _this; } FlatDataProvider.prototype.clone = function () { var a = new FlatDataProvider(); a.deferAutoRefresh = this.deferAutoRefresh; a.executionContext = this.executionContext; a.dataSource = this.dataSource; a.propertiesRequested = this.propertiesRequested; a.schemaHints = this.schemaHints; a.summaryScope = this.summaryScope; a.leftJoinProperty = this.leftJoinProperty; a.rightJoinProperty = this.rightJoinProperty; a.joinCollisionType = this.joinCollisionType; a.joinType = this.joinType; if (this.targetDataSource != null) { a.targetDataSource = this.targetDataSource.clone(); } if (this.rightDataSource != null) { a.rightDataSource = this.rightDataSource.clone(); } for (var b = 0; b < this.groupDescriptions.k.count; b++) { a.groupDescriptions.add(this.groupDescriptions.k.item(b)); } for (var c = 0; c < this.sortDescriptions.k.count; c++) { a.sortDescriptions.add(this.sortDescriptions.k.item(c)); } for (var d = 0; d < this.filterExpressions.k.count; d++) { a.filterExpressions.add(this.filterExpressions.k.item(d)); } for (var e = 0; e < this.summaryDescriptions.k.count; e++) { a.summaryDescriptions.add(this.summaryDescriptions.k.item(e)); } return a; }; FlatDataProvider.prototype.av = function (a, b) { this.r = true; }; FlatDataProvider.prototype.az = function (a, b) { this.r = true; }; FlatDataProvider.prototype.aw = function (a, b) { this.r = true; }; FlatDataProvider.prototype.ay = function (a, b) { this.r = true; }; FlatDataProvider.prototype.ap = function (a, b) { if (this.schemaChanged != null) { this.schemaChanged(this, b); } }; Object.defineProperty(FlatDataProvider.prototype, "targetDataSource", { get: function () { return this.k; }, set: function (a) { var b = this.k; this.k = a; if (b != this.k) { this.ax("TargetDataSource", b, this.k); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "rightDataSource", { get: function () { return this.j; }, set: function (a) { var b = this.j; this.j = a; if (b != this.j) { this.ax("RightDataSource", b, this.j); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "broadcastChangesToRightDataSource", { get: function () { return this.p; }, set: function (a) { var b = this.p; this.p = a; if (b != this.p) { this.ax("BroadcastChangesToRightDataSource", b, this.p); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "leftJoinProperty", { get: function () { return this.z; }, set: function (a) { var b = this.z; this.z = a; if (b != this.z) { this.ax("LeftJoinProperty", b, this.z); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "rightJoinProperty", { get: function () { return this.aa; }, set: function (a) { var b = this.aa; this.aa = a; if (b != this.aa) { this.ax("RightJoinProperty", b, this.aa); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "joinType", { get: function () { return this.h; }, set: function (a) { var b = this.h; this.h = a; if (b != this.h) { this.ax("JoinType", enumGetBox(FlatDataProviderJoinType_$type, b), enumGetBox(FlatDataProviderJoinType_$type, this.h)); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "joinCollisionType", { get: function () { return this.e; }, set: function (a) { var b = this.e; this.e = a; if (b != this.e) { this.ax("JoinCollisionType", enumGetBox(FlatDataProviderJoinCollisionType_$type, b), enumGetBox(FlatDataProviderJoinCollisionType_$type, this.e)); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "schemaHints", { get: function () { return this.ab; }, set: function (a) { var b = this.ab; this.ab = a; if (b != this.ab) { this.ax("SchemaHints", b, this.ab); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "actualSchema", { get: function () { return this.n.actualSchema; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "executionContext", { get: function () { return this.n.executionContext; }, set: function (a) { this.n.executionContext = a; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "updateNotifier", { get: function () { return this.n.updateNotifier; }, set: function (a) { this.n.updateNotifier = a; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "dataSource", { get: function () { return this.w; }, set: function (a) { var b = this.w; this.w = a; if (b != this.w) { this.ax("ItemsSource", b, this.w); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "deferAutoRefresh", { get: function () { return this.q; }, set: function (a) { var b = this.q; this.q = a; if (b != this.q) { this.ax("DeferAutoRefresh", b, this.q); } }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "isSortingSupported", { get: function () { return this.n.isSortingSupported; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "isGroupingSupported", { get: function () { return this.n.isGroupingSupported; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "isFilteringSupported", { get: function () { return this.n.isFilteringSupported; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "sortDescriptions", { get: function () { return this.n.sortDescriptions; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "groupDescriptions", { get: function () { return this.n.groupDescriptions; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "summaryDescriptions", { get: function () { return this.n.summaryDescriptions; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "summaryScope", { get: function () { return this.n.summaryScope; }, set: function (a) { this.n.summaryScope = a; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "filterExpressions", { get: function () { return this.n.filterExpressions; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "propertiesRequested", { get: function () { return this.n.propertiesRequested; }, set: function (a) { this.n.propertiesRequested = a; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "schemaIncludedProperties", { get: function () { return this.n.schemaIncludedProperties; }, set: function (a) { this.n.schemaIncludedProperties = a; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "notifyUsingSourceIndexes", { get: function () { return true; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "isItemIndexLookupSupported", { get: function () { return this.n.isItemIndexLookupSupported; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "isKeyIndexLookupSupported", { get: function () { return this.n.isKeyIndexLookupSupported; }, enumerable: false, configurable: true }); Object.defineProperty(FlatDataProvider.prototype, "actualCount", { get: function () { return this.n.actualCount; }, enumerable: false, configurable: true }); FlatDataProvider.prototype.ax = function (a, b, c) { if (this.propertyChanged != null) { this.propertyChanged(this, new PropertyChangedEventArgs(a)); } this.a5(a, b, c); }; FlatDataProvider.prototype.a5 = function (a, b, c) { switch (a) { case "ItemsSource": this.n.dataSource = c; break; case "DeferAutoRefresh": if (!c) { this.queueAutoRefresh(); } break; case "TargetDataSource": if (b != null) { var d = b; if (d.updateNotifier != null) { if (typeCast(FlatDataProviderTargetDataSourceNotifier.$, d.updateNotifier) !== null) { d.updateNotifier = d.updateNotifier.c; } } d.schemaChanged = delegateRemove(d.schemaChanged, runOn(this, this.au)); } if (c != null) { var e = c; this.n.executionContext = e.executionContext; var f = new FlatDataProviderTargetDataSourceNotifier(this, e.updateNotifier); e.updateNotifier = f; e.schemaChanged = delegateCombine(e.schemaChanged, runOn(this, this.au)); } this.queueAutoRefresh(); break; case "RightDataSource": if (b != null) { var g = b; if (g.updateNotifier != null) { if (typeCast(FlatDataProviderTargetDataSourceNotifier.$, g.updateNotifier) !== null) { g.updateNotifier = g.updateNotifier.c; } } g.schemaChanged = delegateRemove(g.schemaChanged, runOn(this, this.au)); } if (c != null) { var h = c; var i = new FlatDataProviderTargetDataSourceNotifier(this, h.updateNotifier); h.updateNotifier = i; h.schemaChanged = delegateCombine(h.schemaChanged, runOn(this, this.au)); } this.queueAutoRefresh(); break; } }; FlatDataProvider.prototype.au = function (a, b) { this.r = true; this.queueAutoRefresh(); }; FlatDataProvider.prototype.addItem = function (a) { this.n.addItem(a); }; FlatDataProvider.prototype.queueAutoRefresh = function () { if (this.deferAutoRefresh) { return; } if (this.o) { return; } if (this.executionContext != null) { this.o = true; this.executionContext.enqueueAction(runOn(this, this.ar)); } }; FlatDataProvider.prototype.ar = function () { if (this.deferAutoRefresh) { this.o = false; return; } if (!this.o) { return; } this.o = false; this.a6(); }; FlatDataProvider.prototype.a6 = function () { this.a7(); }; FlatDataProvider.prototype.a7 = function () { if (this.k == null) { return; } if (!this.r) { return; } this.r = false; this.k.flushAutoRefresh(); var a = this.k.isVirtual; if (a) { var b = 50; if (typeCast(VirtualDataSource.$, this.k) !== null) { b = this.k.actualPageSize; } this.k.firstVisibleIndexRequested = 0; this.k.lastVisibleIndexRequested = b; } var c = this.b(this.k); if (this.rightDataSource != null && this.rightJoinProperty != null && this.leftJoinProperty != null) { var d = this.b(this.j); c = this.c(c, d); } this.dataSource = c; }; FlatDataProvider.prototype.c = function (a, b) { var c = new List$1(Base.$, 0); var d = this.u(a, this.targetDataSource, false); var e = this.u(b, this.rightDataSource, true); var f = this.joinCollisionType; switch (this.joinType) { case 0: this.aq(c, a, d, this.targetDataSource, b, e, this.rightDataSource, false, f); break; case 1: this.aq(c, a, d, this.targetDataSource, b, e, this.rightDataSource, true, f); break; case 2: f = this.f(f); this.aq(c, b, e, this.rightDataSource, a, d, this.targetDataSource, true, f); break; } return c.toArray(); }; FlatDataProvider.prototype.f = function (a) { switch (a) { case 0: return 0; case 1: return 2; case 2: return 1; case 3: return 4; case 4: return 3; } return 0; }; FlatDataProvider.prototype.u = function (a, b, c) { var d = this.leftJoinProperty; if (c) { d = this.rightJoinProperty; } var e = new Dictionary$2(Base.$, Base.$, 0); for (var f = 0; f < a.length; f++) { var g = a[f]; var h = b.getItemProperty(g, d); e.item(h, g); } return e; }; FlatDataProvider.prototype.createDynamicItem = function () { return {}; }; FlatDataProvider.prototype.setDynamicItemProperty = function (a, b, c) { if (b.charAt(0) == '[') { b = b.substr(1, b.length - 2); } var d = a; d[b] = c; }; FlatDataProvider.prototype.hasDynamicItemProperty = function (a, b) { var c = a; return c[b] != undefined; }; FlatDataProvider.prototype.aq = function (a, b, c, d, e, f, g, h, i) { var j = new HashSet$1(String_$type, 0); var k = new HashSet$1(String_$type, 0); var l = new HashSet$1(String_$type, 0); var m = new List$1(String_$type, 0); var n = new List$1(DataSourceSchemaPropertyType_$type, 0); if (d.actualSchema != null) { for (var o = 0; o < d.actualSchema.propertyNames.length; o++) { var p = d.actualSchema.propertyNames[o]; var q = d.actualSchema.propertyTypes[o]; j.add_1(p); if (!l.contains(p)) { l.add_1(p); m.add(p); n.add(q); } } } if (g.actualSchema != null) { for (var r = 0; r < g.actualSchema.propertyNames.length; r++) { var s = g.actualSchema.propertyNames[r]; var t = g.actualSchema.propertyTypes[r]; k.add_1(s); if (!l.contains(s)) { l.add_1(s); m.add(s); n.add(t); } } } var u = m.toArray(); var v = n.toArray(); for (var w = 0; w < b.length; w++) { var x = b[w]; var y = d.getItemProperty(x, this.leftJoinProperty); var z = f.containsKey(y); if (!z && !h) { continue; } var aa = this.createDynamicItem(); var ab = null; if (z) { ab = f.item(y); } this.at(aa, x, z, j, k, u, v, c, d, ab, f, g, i); a.add1(aa); } }; FlatDataProvider.prototype.at = function (a, b, c, d, e, f, g, h, i, j, k, l, m) { var n = i.actualSchema; var o = l.actualSchema; for (var p = 0; p < f.length; p++) { var q = f[p]; var r = g[p]; var s = d.contains(q) && e.contains(q); if (!s) { if (d.contains(q)) { var t = i.getItemProperty(b, q); this.setDynamicItemProperty(a, q, t); continue; } else { var u = l.getItemProperty(j, q); this.setDynamicItemProperty(a, q, u); continue; } } var v = m; if (q == this.leftJoinProperty) { v = 1; } switch (v) { case 0: var w = i.getItemProperty(b, q); this.setDynamicItemProperty(a, q, w); continue; case 1: var x = i.getItemProperty(b, q); this.setDynamicItemProperty(a, q, x); continue; case 2: if (c) { var y = l.getItemProperty(j, q); this.setDynamicItemProperty(a, q, y); continue; } else { this.setDynamicItemProperty(a, q, this.y(r)); continue; } case 3: var z = i.getItemProperty(b, q); this.setDynamicItemProperty(a, q, z); continue; case 4: if (c) { var aa = l.getItemProperty(j, q); this.setDynamicItemProperty(a, q, aa); continue; } else { var ab = i.getItemProperty(b, q); this.setDynamicItemProperty(a, q, ab); continue; } } } }; FlatDataProvider.prototype.y = function (a) { return null; }; FlatDataProvider.prototype.flushAutoRefresh = function () { this.ar(); }; FlatDataProvider.prototype.refresh = function () { this.a6(); }; FlatDataProvider.prototype.getItemAtIndex = function (a) { return this.n.getItemAtIndex(a); }; FlatDataProvider.prototype.getItemValue = function (a, b) { return this.n.getItemValue(a, b); }; FlatDataProvider.prototype.indexOfItem = function (a) { return this.n.indexOfItem(a); }; FlatDataProvider.prototype.indexOfKey = function (a) { return this.n.indexOfKey(a); }; FlatDataProvider.prototype.removeItem = function (a) { this.n.removeItem(a); }; FlatDataProvider.prototype.resolveSchemaPropertyType = function (a) { return this.n.resolveSchemaPropertyType(a); }; FlatDataProvider.prototype.setItemValue = function (a, b, c) { this.n.setItemValue(a, b, c); }; FlatDataProvider.prototype.notifyClearItems = function () { if (this.targetDataSource != null) { this.targetDataSource.notifyClearItems(); } if (this.rightDataSource != null && this.broadcastChangesToRightDataSource) { this.rightDataSource.notifyClearItems(); } }; FlatDataProvider.prototype.notifyInsertItem = function (a, b) { if (this.targetDataSource != null) { this.targetDataSource.notifyInsertItem(a, b); } if (this.rightDataSource != null && this.broadcastChangesToRightDataSource) { this.rightDataSource.notifyInsertItem(a, b); } }; FlatDataProvider.prototype.notifyRemoveItem = function (a, b) { if (this.targetDataSource != null) { this.targetDataSource.notifyRemoveItem(a, b); } if (this.rightDataSource != null && this.broadcastChangesToRightDataSource) { this.rightDataSource.notifyRemoveItem(a, b); } }; FlatDataProvider.prototype.notifySetItem = function (a, b, c) { if (this.targetDataSource != null) { this.targetDataSource.notifySetItem(a, b, c); } if (this.rightDataSource != null && this.broadcastChangesToRightDataSource) { this.rightDataSource.notifySetItem(a, b, c); } }; FlatDataProvider.prototype.v = function (a) { return a.groupDescriptions.k.count; }; FlatDataProvider.prototype.b = function (a) { var b = this.d(a); return b; }; FlatDataProvider.prototype.as = function (a, b) { var c = this.k; if (this.a != null) { for (var d = 0; d < c.actualCount; d++) { var e = c.getRowType(d); { var f = c.getItemAtIndex(d); this.a[d] = f; } } } this.n.notifyClearItems(); }; FlatDataProvider.prototype.d = function (a) { var b = new List$1(Base.$, 0); for (var c = 0; c < a.actualCount; c++) { var d = a.getRowType(c); var e = a.getItemAtIndex(c); b.add1(e); } this.a = b.toArray(); return this.a; }; FlatDataProvider.prototype.a0 = function () { this.r = true; this.queueAutoRefresh(); }; FlatDataProvider.prototype.a1 = function (a, b) { this.r = true; this.queueAutoRefresh(); }; FlatDataProvider.prototype.a2 = function (a, b) { this.r = true; this.queueAutoRefresh(); }; FlatDataProvider.prototype.a3 = function (a, b, c) { this.r = true; this.queueAutoRefresh(); }; FlatDataProvider.prototype.a4 = function (a, b) { this.as(a, b); if (this.k.lastVisibleIndexRequested < this.k.actualCount) { var c = this.k.lastVisibleIndexRequested - this.k.firstVisibleIndexRequested; this.k.lastVisibleIndexRequested += c; this.k.firstVisibleIndexRequested += c; } }; FlatDataProvider.$t = markType(FlatDataProvider, 'FlatDataProvider', Base.$, [IDataSourceLocalDataProvider_$type, INotifyPropertyChanged_$type]); return FlatDataProvider; }(Base)); export { FlatDataProvider }; /** * @hidden */ var FlatDataProviderTargetDataSourceNotifier = /** @class */ /*@__PURE__*/ (function (_super) { __extends(FlatDataProviderTargetDataSourceNotifier, _super); function FlatDataProviderTargetDataSourceNotifier(a, b) { var _this = _super.call(this) || this; _this.a = null; _this.b = null; _this.a = a; _this.b = b; return _this; } Object.defineProperty(FlatDataProviderTargetDataSourceNotifier.prototype, "c", { get: function () { return this.b; }, enumerable: false, configurable: true }); FlatDataProviderTargetDataSourceNotifier.prototype.notifyClearItems = function () { this.a.a0(); if (this.b != null) { this.b.notifyClearItems(); } }; FlatDataProviderTargetDataSourceNotifier.prototype.notifyInsertItem = function (a, b) { this.a.a1(a, b); if (this.b != null) { this.b.notifyInsertItem(a, b); } }; FlatDataProviderTargetDataSourceNotifier.prototype.notifyRemoveItem = function (a, b) { this.a.a2(a, b); if (this.b != null) { this.b.notifyRemoveItem(a, b); } }; FlatDataProviderTargetDataSourceNotifier.prototype.notifySetItem = function (a, b, c) { this.a.a3(a, b, c); if (this.b != null) { this.b.notifySetItem(a, b, c); } }; FlatDataProviderTargetDataSourceNotifier.prototype.rangeActualized = function (a, b) { this.a.a4(a, b); if (this.b != null) { this.b.rangeActualized(a, b); } }; FlatDataProviderTargetDataSourceNotifier.$t = markType(FlatDataProviderTargetDataSourceNotifier, 'FlatDataProviderTargetDataSourceNotifier', Base.$, [IDataSourceUpdateNotifier_$type]); return FlatDataProviderTargetDataSourceNotifier; }(Base)); export { FlatDataProviderTargetDataSourceNotifier };