igniteui-react-grids
Version:
Ignite UI React grid components.
112 lines (110 loc) • 3.25 kB
JavaScript
import * as React from 'react';
import { IgrGridActionsBaseDirective } from "./igr-grid-actions-base-directive";
import { GridEditingActions } from "./GridEditingActions";
import { isValidProp, ensureBool } from "igniteui-react-core";
/**
* Grid Editing Actions for the Action Strip
* @igxParent IgxActionStripComponent
*/
export class IgrGridEditingActions extends IgrGridActionsBaseDirective {
createImplementation() {
var _a, _b;
let impl = new GridEditingActions();
let nat;
if (typeof document !== 'undefined') {
nat = document.createElement("igc-grid-editing-actions");
}
else {
nat = {
style: {}
};
}
if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.className) {
nat.className = this.props.className;
}
if ((_b = this.props) === null || _b === void 0 ? void 0 : _b.id) {
nat.id = this.props.id;
}
impl.setNativeElement(nat);
return impl;
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
constructor(props) {
super(props);
this._getMainRef = this._getMainRef.bind(this);
}
render() {
const nativePropsName = Object.keys(this.props).filter(prop => !isValidProp(this, prop) && prop !== "originalRef" && prop !== "className");
const nativeProps = {};
nativePropsName.forEach(propName => {
nativeProps[propName] = this.props[propName];
});
let propChildren = this.props.children;
let children = [];
React.Children.forEach(propChildren, (ch) => {
children.push(React.cloneElement(ch));
});
this._portalManager.onRender(children);
let style = {};
style.display = 'contents';
if (this.props.style) {
style = this.props.style;
}
let div = React.createElement("div", Object.assign(Object.assign({}, nativeProps), { ref: this._getMainRef, style: style, children: children }));
return div;
}
_getMainRef(ref) {
this._elRef = ref;
}
/**
* An input to enable/disable action strip row adding button
*/
get addRow() {
return this.i.i;
}
set addRow(v) {
this.i.i = ensureBool(v);
}
/**
* An input to enable/disable action strip row editing button
*/
get editRow() {
return this.i.k;
}
set editRow(v) {
this.i.k = ensureBool(v);
}
/**
* An input to enable/disable action strip row deleting button
*/
get deleteRow() {
return this.i.j;
}
set deleteRow(v) {
this.i.j = ensureBool(v);
}
/**
* An input to enable/disable action strip child row adding button
*/
get addChild() {
return this.i.h;
}
set addChild(v) {
this.i.h = ensureBool(v);
}
/**
* Enter row or cell edit mode depending the grid rowEditable option
* @example
* ```typescript
* this.gridEditingActions.startEdit();
* ```
*/
startEdit(evt) {
this.i.l(evt);
}
}