igniteui-react-grids
Version:
Ignite UI React grid components.
230 lines (229 loc) • 6.52 kB
JavaScript
import { IgrPivotKeys } from "./igr-pivot-keys";
import { PivotConfiguration as PivotConfiguration_internal } from "./PivotConfiguration";
import { interfaceToInternal } from "igniteui-react-core";
import { PivotDimensionStrategy } from "./PivotDimensionStrategy";
import { IgrPivotDimension } from "./igr-pivot-dimension";
import { IgrPivotValue } from "./igr-pivot-value";
/**
* Configuration of the pivot grid.
*/
export class IgrPivotConfiguration {
createImplementation() {
let impl = new PivotConfiguration_internal();
if (impl.setNativeElement) {
impl.setNativeElement({});
}
return impl;
}
get nativeElement() {
return this._implementation.nativeElement;
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
onImplementationCreated() {
}
constructor() {
this.mounted = false;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
_provideImplementation(i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
/**
* A strategy to transform the rows.
*/
get rowStrategy() {
return this.i.f.nativeElement;
}
set rowStrategy(v) {
this.i.f = interfaceToInternal(v, () => new PivotDimensionStrategy());
}
/**
* A strategy to transform the columns.
*/
get columnStrategy() {
return this.i.e.nativeElement;
}
set columnStrategy(v) {
this.i.e = interfaceToInternal(v, () => new PivotDimensionStrategy());
}
/**
* A list of the rows.
*/
get rows() {
if (!this.i.c) {
return undefined;
}
let ret = [];
for (let i = 0; i < this.i.c.length; i++) {
let impl = this.i.c[i];
if (!impl.externalObject) {
if (impl instanceof IgrPivotDimension) {
ret.push(impl);
continue;
}
let e = new IgrPivotDimension();
e._implementation = impl;
impl.externalObject = e;
}
ret.push(impl.externalObject);
}
return ret;
}
set rows(v) {
let arr = [];
for (let i = 0; i < v.length; i++) {
arr.push(v[i].i);
}
this.i.c = arr;
}
/**
* A list of the columns.
*/
get columns() {
if (!this.i.a) {
return undefined;
}
let ret = [];
for (let i = 0; i < this.i.a.length; i++) {
let impl = this.i.a[i];
if (!impl.externalObject) {
if (impl instanceof IgrPivotDimension) {
ret.push(impl);
continue;
}
let e = new IgrPivotDimension();
e._implementation = impl;
impl.externalObject = e;
}
ret.push(impl.externalObject);
}
return ret;
}
set columns(v) {
let arr = [];
for (let i = 0; i < v.length; i++) {
arr.push(v[i].i);
}
this.i.a = arr;
}
/**
* A list of the values.
*/
get values() {
if (!this.i.d) {
return undefined;
}
let ret = [];
for (let i = 0; i < this.i.d.length; i++) {
let impl = this.i.d[i];
if (!impl.externalObject) {
if (impl instanceof IgrPivotValue) {
ret.push(impl);
continue;
}
let e = new IgrPivotValue();
e._implementation = impl;
impl.externalObject = e;
}
ret.push(impl.externalObject);
}
return ret;
}
set values(v) {
let arr = [];
for (let i = 0; i < v.length; i++) {
arr.push(v[i].i);
}
this.i.d = arr;
}
/**
* Dimensions to be displayed in the filter area.
*/
get filters() {
if (!this.i.b) {
return undefined;
}
let ret = [];
for (let i = 0; i < this.i.b.length; i++) {
let impl = this.i.b[i];
if (!impl.externalObject) {
if (impl instanceof IgrPivotDimension) {
ret.push(impl);
continue;
}
let e = new IgrPivotDimension();
e._implementation = impl;
impl.externalObject = e;
}
ret.push(impl.externalObject);
}
return ret;
}
set filters(v) {
let arr = [];
for (let i = 0; i < v.length; i++) {
arr.push(v[i].i);
}
this.i.b = arr;
}
/**
* Pivot data keys used for data generation. Can be used for custom remote scenarios where the data is pre-populated.
*/
get pivotKeys() {
const r = this.i.g;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrPivotKeys();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set pivotKeys(v) {
v == null ? this.i.g = null : this.i.g = v.i;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.rowStrategy && this.rowStrategy.name && this.rowStrategy.name == name) {
return this.rowStrategy;
}
if (this.columnStrategy && this.columnStrategy.name && this.columnStrategy.name == name) {
return this.columnStrategy;
}
if (this.pivotKeys && this.pivotKeys.name && this.pivotKeys.name == name) {
return this.pivotKeys;
}
return null;
}
setNativeElement(element) {
this.i.setNativeElement(element);
}
}