UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

963 lines (962 loc) 33.9 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, IList_$type, runOn, String_$type, EnumUtil, typeCast, Array_$type, fromEnum, delegateRemove, delegateCombine, markType } from "./type"; import { IDataSourceLocalDataProvider_$type } from "./IDataSourceLocalDataProvider"; import { IDataSourceSchema_$type } from "./IDataSourceSchema"; import { DataSourceSchemaPropertyType_$type } from "./DataSourceSchemaPropertyType"; import { DefaultDataSourceSchema } from "./DefaultDataSourceSchema"; import { SortDescriptionCollection } from "./SortDescriptionCollection"; import { FilterExpressionCollection } from "./FilterExpressionCollection"; import { SummaryDescriptionCollection } from "./SummaryDescriptionCollection"; import { Dictionary$2 } from "./Dictionary$2"; import { FastReflectionHelper } from "./FastReflectionHelper"; import { HashSet$1 } from "./HashSet$1"; import { DataSourceDataProviderSchemaChangedEventArgs } from "./DataSourceDataProviderSchemaChangedEventArgs"; import { List$1 } from "./List$1"; import { FastIterationDictionary$2 } from "./FastIterationDictionary$2"; import { INotifyCollectionChanged_$type } from "./INotifyCollectionChanged"; import { getAllPropertyNames } from "./componentUtil"; import { stringStartsWith } from "./string"; /** * @hidden */ export let DataSourceLocalDataProvider = /*@__PURE__*/ (() => { class DataSourceLocalDataProvider extends Base { constructor() { super(); this.o = null; this.n = null; this.g = null; this.p = null; this.f = 0; this.ac = 5; this.ad = 10; this.ag = null; this.w = new Dictionary$2(String_$type, DataSourceSchemaPropertyType_$type, 0); this.aj = null; this.schemaChanged = null; this.v = new Dictionary$2(String_$type, FastReflectionHelper.$, 0); this.x = new HashSet$1(String_$type, 0); this.j = null; this.aa = null; this.s = false; this.i = null; this.h = null; this.r = false; this.a = null; this.q = false; this.b = null; this.o = new SortDescriptionCollection(); this.o.n(runOn(this, this.a3)); this.n = new SortDescriptionCollection(); this.p = new SummaryDescriptionCollection(); this.g = new FilterExpressionCollection(); } a3(a, b) { this.queueAutoRefresh(); } clone() { let a = new DataSourceLocalDataProvider(); a.deferAutoRefresh = this.deferAutoRefresh; a.executionContext = this.executionContext; a.dataSource = this.dataSource; a.propertiesRequested = this.propertiesRequested; a.schemaHints = this.schemaHints; a.summaryScope = this.summaryScope; 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; } get maxDepth() { return this.ac; } set maxDepth(a) { let b = a; this.ac = a; if (b != a) { this.az("MaxDepth", b, a); } } get maxIteration() { return this.ad; } set maxIteration(a) { let b = a; this.ad = a; if (b != a) { this.az("MaxIteration", b, a); } } get dataSource() { return this.ag; } set dataSource(a) { let b = this.ag; this.ag = a; if (b != this.ag) { this.ax("ItemsSource", b, this.ag); } } get schemaHints() { return this.aj; } set schemaHints(a) { let b = this.aj; this.aj = a; if (b != this.aj) { this.ax("SchemaHints", b, this.aj); } } ay() { if (this.aj == null) { return; } this.w.clear(); let a = this.aj.split(','); for (let b = 0; b < a.length; b++) { let c = a[b].trim().split(':'); if (c.length != 2) { continue; } let d = c[0]; let e = this.d(c[1]); this.w.addItem(d, e); } } d(a) { let b = EnumUtil.parse(DataSourceSchemaPropertyType_$type, a, true); if (b != null) { return EnumUtil.getEnumValue(DataSourceSchemaPropertyType_$type, b); } return 11; } getItemAtIndex(a) { if (this.aa == null) { return null; } if (this.s) { return this.aa[a]; } return this.aa.item(a); } getItemValue(a, b) { this.as(); let c; let d = this.v.tryGetValue(b, c); c = d.p1; if (c == null && !this.x.contains(b)) { let e = b.split('.'); let f = a; let g = true; for (let h = 0; h < e.length; h++) { f = f[e[h]]; if ((f === undefined)) { g = false; break; } } if (g) { c = new FastReflectionHelper(false, b); this.v.addItem(b, c); } else { this.x.add_1(b); } } if (c == null) { return null; } let val_ = c.getPropertyValue(a); if ((val_ === undefined)) { return null; } return val_; } setItemValue(a, b, c) { this.as(); let d; let e = this.v.tryGetValue(b, d); d = e.p1; if (d == null) { return; } d.setPropertyValue(a, c); } removeItem(a) { if (this.aa != null) { let b = this.aa.indexOf(a); if (this.s) { this.aa.splice(b, 1); } else { this.aa.removeAt(b); } this.notifyRemoveItem(b, a); } } addItem(a) { if (this.aa != null) { let b = this.actualCount; if (this.s) { this.aa.splice(b, 0, a); } else { this.aa.insert(b, a); } this.notifyInsertItem(this.actualCount - 1, a); } } as() { if (this.j == null) { this.j = this.actualSchema; if (this.schemaChanged != null) { this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this.j, this.actualCount)); } } } get actualCount() { if (this.aa == null) { return 0; } if (this.s) { return (this.aa.length); } return this.aa.count; } get actualSchema() { if (this.j == null) { if (this.aa == null) { this.j = new DefaultDataSourceSchema([], [], null, null, []); } else { this.j = this.m(); } } return this.j; } m() { this.v.clear(); this.x.clear(); return this.k(this.aa, this.maxIteration, this.maxDepth, null, 0); } k(a, b, c, d, e) { if (e >= c) { return null; } if (a == null) { if (e == 0) { return new DefaultDataSourceSchema([], [], null, null, []); } else { return null; } } let f = 0; let g = typeCast(Array_$type, a) !== null; if (g) { f = (a.length); } else { f = a.count; } if (f == 0) { return new DefaultDataSourceSchema([], [], null, null, []); } let h = null; let i = new FastIterationDictionary$2(String_$type, DataSourceSchemaPropertyType_$type, 0); let j = new HashSet$1(String_$type, 0); let k = 0; let l = new List$1(List$1.$.specialize(String_$type), 0); let m = new List$1(IDataSourceSchema_$type, 0); if (this.schemaIncludedProperties == null || this.schemaIncludedProperties.length > 0) { this.at(a, b, (n, o) => { if (n == null) { return true; } if ((typeof n === 'function')) { return true; } if ((Array.isArray(n))) { return true; } let check_ = n; if ((check_ instanceof HTMLElement)) { return true; } if ((check_ instanceof Date)) { return false; } if ((typeof check_ === 'number')) { return false; } if ((typeof check_ === 'string')) { return false; } if ((typeof check_ === 'boolean')) { return false; } if ((typeof check_ === 'bigint')) { return false; } if (h == null) { h = this.y(n); } for (let p = 0; p < h.count; p++) { let q = h._inner[p]; if (j.contains(q)) { continue; } let r = d == null ? q : d + "." + q; if (this.schemaIncludedProperties != null && this.schemaIncludedProperties.length > 0) { let s = false; for (let t = 0; t < this.schemaIncludedProperties.length; t++) { if (this.schemaIncludedProperties[t] == r) { s = true; break; } } if (!s) { k++; continue; } } if (!this.t(check_, q)) { k++; continue; } if (i.d(q)) { i.s(q, 11); this.v.addItem(r, new FastReflectionHelper(false, r)); } if (this.w.containsKey(r)) { i.item(q, this.w.item(r)); this.w.removeItem(r); j.add_1(q); k++; } else { let u = this.ai(n, q); if (u != null) { i.item(q, DataSourceLocalDataProvider.e(u)); j.add_1(q); k++; } else { continue; } } l.add(this.z(n, q)); if (i.item(q) == 11) { let v = this.ai(n, q); if (typeCast(Array_$type, v) !== null) { m.add(this.k(v, b, c, r, e + 1)); } else { let w = new List$1(Base.$, 0); w.add1(v); m.add(this.k(w, 1, c, r, e + 1)); } } else { m.add(null); } } return !(k == h.count); }); for (let n of fromEnum(this.w)) { let o = n.key.split('.'); for (let p = 0; p < o.length; p++) { if (j.contains(o[p])) { continue; } else { i.s(o[p], p == o.length - 1 ? n.value : 11); j.add_1(o[p]); l.add(new List$1(String_$type, 0)); } } } } else { return new DefaultDataSourceSchema([], [], null, null, []); } let q = new Array(l.count); for (let r = 0; r < l.count; r++) { q[r] = l._inner[r].toArray(); } return new DefaultDataSourceSchema(i.o.toArray(), i.q.toArray(), null, q, m.toArray()); } t(a, b) { if (stringStartsWith(b, "_")) { return false; } if (b == "$hashCode" || b == "$type") { return false; } if ((typeof a[b] === 'function')) { return false; } return true; } l(a, b, c) { if (c >= this.maxDepth) { return null; } if (a == null) { return null; } if ((typeof a === 'function')) { return null; } if ((Array.isArray(a))) { return null; } let check_ = a; if ((check_ instanceof HTMLElement)) { return null; } let d = new List$1(String_$type, 0); let e = new HashSet$1(String_$type, 0); let f = new List$1(DataSourceSchemaPropertyType_$type, 0); let g = new List$1(List$1.$.specialize(String_$type), 0); let h = this.y(a); let i = new List$1(IDataSourceSchema_$type, 0); if (this.schemaIncludedProperties == null || this.schemaIncludedProperties.length > 0) { for (let j = 0; j < h.count; j++) { let k = h._inner[j]; if (this.schemaIncludedProperties != null && this.schemaIncludedProperties.length > 0) { let l = false; for (let m = 0; m < this.schemaIncludedProperties.length; m++) { if (this.schemaIncludedProperties[m] == k) { l = true; break; } } if (!l) { continue; } } if (stringStartsWith(k, "_")) { continue; } if (k == "$hashCode" || k == "$type") { continue; } if ((typeof check_[k] === 'function')) { continue; } if (e.contains(k)) { continue; } else { let n = b == null ? k : b + "." + k; d.add(k); e.add_1(k); this.v.addItem(n, new FastReflectionHelper(false, n)); if (this.w.containsKey(n)) { f.add(this.w.item(n)); this.w.removeItem(n); } else { f.add(this.c(a, k)); } g.add(this.z(a, k)); if (f._inner[f.count - 1] == 11) { i.add(this.l(a[k], n, c + 1)); } else { i.add(null); } } } for (let o of fromEnum(this.w)) { let p = o.key.split('.'); for (let q = 0; q < p.length; q++) { if (e.contains(p[q])) { continue; } else { d.add(p[q]); e.add_1(p[q]); f.add(q == p.length - 1 ? o.value : 11); g.add(new List$1(String_$type, 0)); } } } } let r = new Array(g.count); for (let s = 0; s < g.count; s++) { r[s] = g._inner[s].toArray(); } return new DefaultDataSourceSchema(d.toArray(), f.toArray(), null, r, i.toArray()); } resolveSchemaPropertyType(a) { let b = a.split('.'); let c = a.indexOf("[") >= 0; if (b.length == 1) { for (let d = 0; d < this.actualSchema.propertyNames.length; d++) { if (this.actualSchema.propertyNames[d] == b[0]) { return this.actualSchema.propertyTypes[d]; } } if (c) { let e = this.ah(); let f = this.getItemValue(e, a); if (f == null) { return 11; } else { return DataSourceLocalDataProvider.e(f); } } return 11; } else { let g = this.ah(); let h = this.getItemValue(g, a); if (h == null) { return 11; } else { return DataSourceLocalDataProvider.e(h); } } } setSchema(a) { this.j = a; if (this.schemaChanged != null) { this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this.j, this.actualCount)); } } y(schemaItem_) { let a = new HashSet$1(String_$type, 0); let propertyKey_ = null; let ret_ = new List$1(String_$type, 0); let exclusions_ = {}; for (propertyKey_ in schemaItem_) { if (!isNaN(propertyKey_)) { continue; } if (!exclusions_.hasOwnProperty(propertyKey_)) { ret_.add(propertyKey_); } } ; for (let b of fromEnum(ret_)) { a.add_1(b); } let c = (getAllPropertyNames(schemaItem_)); for (let e = 0; e < c.length; e++) { let d = c[e]; if (!a.contains(d)) { a.add_1(d); ret_.add(d); } } return ret_; } av(a, item_, propertyName_, b) { if ((item_.__dataIntents !== undefined)) { if ((item_.__dataIntents[propertyName_] !== undefined)) { this.au(a, item_, propertyName_); } let selfName_ = "self." + propertyName_; if (!b && (item_.__dataIntents[selfName_] !== undefined)) { this.au(a, item_, selfName_); } let selfName2_ = "self_" + propertyName_; if (!b && (item_.__dataIntents[selfName2_] !== undefined)) { this.au(a, item_, selfName2_); } } } au(a, item_, propertyName_) { let val_ = item_.__dataIntents[propertyName_]; let b = typeCast(Array_$type, val_) !== null; if (!b) { b = (Array.isArray(val_)); } if (b) { let c = val_; for (let d = 0; d < c.length; d++) { if (c[d] != null) { a.add(c[d].toString()); } } } } z(item_, propertyName_) { let a = new List$1(String_$type, 0); let list_ = this.aa; let dataIntents_ = null; this.av(a, item_, propertyName_, false); this.av(a, list_, propertyName_, true); return a; } ai(item_, propertyName_) { if ((item_[propertyName_] == undefined)) { return null; } return item_[propertyName_]; } c(item_, propertyName_) { if (item_ == null) { return 11; } if ((item_[propertyName_] == undefined)) { return 11; } let value_ = item_[propertyName_]; return DataSourceLocalDataProvider.e(value_); } static e(value_) { if (value_ == null) { return 11; } if ((typeof value_ == 'number')) { return 5; } if ((typeof value_ == 'boolean')) { return 2; } if ((typeof value_ == 'string')) { return 0; } if ((typeof value_ == 'object')) { if ((value_ instanceof Date)) { return 8; } } return 11; } ah() { let a = 0; if (this.s) { a = (this.aa.length); } else { a = this.aa.count; } for (let b = 0; b < a; b++) { let c; if (this.s) { c = this.aa[b]; } else { c = this.aa.item(b); } if (c != null) { return c; } } return null; } at(a, b, c) { let d = typeCast(Array_$type, a) !== null; let e = 0; if (d) { e = (a.length); } else { e = a.count; } if (b > 0) { e = Math.min(e, b); } for (let f = 0; f < e; f++) { let g; if (d) { g = a[f]; } else { g = a.item(f); } if (!c(g, f)) { break; } } } ax(a, b, c) { this.az(a, b, c); } get ab() { return this.aa; } az(a, b, c) { switch (a) { case "ItemsSource": this.j = null; if (b != null) { if (typeCast(INotifyCollectionChanged_$type, b) !== null) { let d = typeCast(INotifyCollectionChanged_$type, b); d.collectionChanged = delegateRemove(d.collectionChanged, runOn(this, this.aw)); } } if (this.dataSource != null) { this.s = false; if (typeCast(Array_$type, this.dataSource) !== null) { this.s = true; this.aa = this.dataSource; } else if (typeCast(IList_$type, this.dataSource) !== null) { this.aa = this.dataSource; } if (!this.s && this.aa == null) { let source_ = this.dataSource; this.s = (Array.isArray(source_)); if (this.s) { this.aa = this.dataSource; } } if (typeCast(INotifyCollectionChanged_$type, this.dataSource) !== null) { let e = typeCast(INotifyCollectionChanged_$type, this.dataSource); e.collectionChanged = delegateCombine(e.collectionChanged, runOn(this, this.aw)); } } else { this.aa = null; } this.as(); break; case "DeferAutoRefresh": if (!c) { this.queueAutoRefresh(); } break; case "SchemaHints": this.j = null; this.ay(); this.as(); break; case "MaxDepth": case "MaxIteration": this.j = null; this.as(); break; } } aw(a, b) { switch (b.action) { case 0: if (b.newItems != null) { this.notifyInsertItem(b.newStartingIndex, b.newItems.item(0)); } break; case 1: if (b.oldItems != null) { this.notifyRemoveItem(b.oldStartingIndex, b.oldItems.item(0)); } break; case 2: if (b.newItems != null) { this.notifySetItem(b.newStartingIndex, b.oldItems.item(0), b.newItems.item(0)); } break; case 4: this.notifyClearItems(); break; } } get executionContext() { return this.i; } set executionContext(a) { this.i = a; } get u() { return false; } notifySetItem(a, b, c) { if (this.u) { if (this.s) { this.aa[a] = c; } else { this.aa.item(a, c); } } if (this.updateNotifier != null) { this.updateNotifier.notifySetItem(a, b, c); } } notifyClearItems() { if (this.u) { if (this.s) { this.aa.length = 0; } else { this.aa.clear(); } } if (this.updateNotifier != null) { this.updateNotifier.notifyClearItems(); } } notifyInsertItem(a, b) { if (this.u) { if (this.s) { this.aa.splice(a, 0, b); } else { this.aa.insert(a, b); } } let c = 0; if (this.s) { c = (this.aa.length); } else { c = this.aa.count; } if (this.aa != null && c == 1 && (this.actualSchema == null || this.actualSchema.propertyNames.length == 0)) { this.j = null; this.as(); } if (this.updateNotifier != null) { this.updateNotifier.notifyInsertItem(a, b); } } notifyRemoveItem(a, b) { if (this.u) { if (this.s) { this.aa.splice(a, 1); } else { this.aa.remove(a); } } if (this.updateNotifier != null) { this.updateNotifier.notifyRemoveItem(a, b); } } get updateNotifier() { return this.h; } set updateNotifier(a) { this.h = a; } get deferAutoRefresh() { return this.r; } set deferAutoRefresh(a) { let b = this.r; this.r = a; if (this.r != b) { this.ax("DeferAutoRefresh", b, this.r); } } get isSortingSupported() { return false; } get isFilteringSupported() { return false; } get sortDescriptions() { return this.o; } get filterExpressions() { return this.g; } get summaryDescriptions() { return this.p; } get summaryScope() { return this.f; } set summaryScope(a) { this.f = a; } get notifyUsingSourceIndexes() { return true; } get propertiesRequested() { return this.a; } set propertiesRequested(a) { let b = this.a; this.a = a; if (b != this.a) { } } get isItemIndexLookupSupported() { return true; } get isKeyIndexLookupSupported() { return false; } get isGroupingSupported() { return false; } get groupDescriptions() { return this.n; } queueAutoRefresh() { if (this.deferAutoRefresh) { return; } if (this.q) { return; } if (this.executionContext != null) { this.q = true; this.executionContext.enqueueAction(runOn(this, this.ar)); } } ar() { if (this.deferAutoRefresh) { this.q = false; return; } if (!this.q) { return; } this.q = false; this.a0(); } a0() { this.a1(); } a1() { } flushAutoRefresh() { this.ar(); } refresh() { this.a0(); } indexOfItem(a) { if (this.aa == null) { return -1; } return this.aa.indexOf(a); } indexOfKey(a) { return -1; } get schemaIncludedProperties() { return this.b; } set schemaIncludedProperties(a) { let b = this.b; this.b = a; if (b != this.b) { } } } DataSourceLocalDataProvider.$t = markType(DataSourceLocalDataProvider, 'DataSourceLocalDataProvider', Base.$, [IDataSourceLocalDataProvider_$type]); return DataSourceLocalDataProvider; })();