igniteui-react-core
Version:
Ignite UI React Core.
133 lines (132 loc) • 3.56 kB
JavaScript
import { ensureBool } from "./componentUtil";
import { FilterExpressionCollection as FilterExpressionCollection_internal } from "./FilterExpressionCollection";
/**
* Represents a colleciton of filter expressions.
*/
export class IgrFilterExpressionCollection {
createImplementation() {
return new FilterExpressionCollection_internal();
}
get i() {
return this._implementation;
}
onImplementationCreated() {
}
constructor() {
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
}
_provideImplementation(i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
}
item(index, value) {
let filter = null;
if (value !== undefined) {
filter = this.set(index, value == null ? null : value);
}
else {
filter = this.get(index);
}
return filter;
}
get count() {
return this.i.size();
}
toArray() {
let arr = [];
for (let i = 0; i < this.count; i++) {
arr[i] = this.item(i);
}
return arr;
}
*[Symbol.iterator]() {
for (let i = 0; i < this.count; i++) {
let item = this.item(i);
if (item.externalObject) {
item = item.externalObject;
}
yield item;
}
}
get syncTarget() {
const r = this.i.syncTarget;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrFilterExpressionCollection();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set syncTarget(v) {
v == null ? this.i.syncTarget = null : this.i.syncTarget = v.i;
}
/**
* Gets or sets whether this collection should detach the sync when the target collection changes.
*/
get shouldDetachOnTargetChange() {
return this.i.shouldDetachOnTargetChange;
}
set shouldDetachOnTargetChange(v) {
this.i.shouldDetachOnTargetChange = ensureBool(v);
}
get onChanged() {
return this.i.onChanged;
}
set onChanged(v) {
this.i.onChanged = v;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.syncTarget != null && this.syncTarget.findByName && this.syncTarget.findByName(name)) {
return this.syncTarget.findByName(name);
}
return null;
}
add(item) {
let iv = this.i.add(item);
return (iv);
}
insert(index, item) {
this.i.insert(index, item);
}
clear() {
this.i.clear();
}
get(index) {
let iv = this.i.get(index);
return (iv);
}
indexOf(item) {
let iv = this.i.indexOf(item);
return (iv);
}
remove(item) {
let iv = this.i.remove(item);
return (iv);
}
removeAt(index) {
let iv = this.i.removeAt(index);
return (iv);
}
set(index, value) {
let iv = this.i.set(index, value);
return (iv);
}
}