UNPKG

igniteui-react-core

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