UNPKG

@progress/kendo-react-grid

Version:
86 lines 3.8 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import * as React from 'react'; import { getNestedValue } from './../utils'; import { NumericTextBox } from '@progress/kendo-react-inputs'; import { DatePicker } from '@progress/kendo-react-dateinputs'; import { guid } from '@progress/kendo-react-common'; /** * @hidden */ var GridEditCell = /** @class */ (function (_super) { __extends(GridEditCell, _super); function GridEditCell() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._inputId = guid(); /** * @hidden */ _this.handleOnChange = function (syntheticEvent) { if (_this.props.onChange) { var value = syntheticEvent.target.type === 'checkbox' ? syntheticEvent.target.checked : syntheticEvent.target.value; _this.props.onChange({ dataItem: _this.props.dataItem, field: _this.props.field, syntheticEvent: syntheticEvent, value: value }); } }; /** * @hidden */ _this.inputChange = function (e) { if (_this.props.onChange) { _this.props.onChange({ dataItem: _this.props.dataItem, field: _this.props.field, syntheticEvent: e.syntheticEvent, value: e.value }); } }; return _this; } /** * @hidden */ GridEditCell.prototype.render = function () { var data = getNestedValue(this.props.field, this.props.dataItem); var defaultRendering = null; switch (this.props.editor) { case 'numeric': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement(NumericTextBox, { width: "100%", value: (data === undefined) ? null : data, onChange: this.inputChange }))); break; case 'date': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement(DatePicker, { width: "100%", value: data, onChange: this.inputChange }))); break; case 'boolean': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement("input", { checked: data || false, id: this._inputId, type: "checkbox", className: "k-checkbox", onChange: this.handleOnChange }), React.createElement("label", { className: "k-checkbox-label", htmlFor: this._inputId }))); break; default: defaultRendering = (React.createElement("td", { className: this.props.className, style: this.props.style }, React.createElement("input", { style: { width: '100%' }, className: "k-textbox", value: data || '', onChange: this.handleOnChange }))); } return this.props.render ? this.props.render.call(undefined, defaultRendering, this.props) : defaultRendering; }; return GridEditCell; }(React.Component)); export { GridEditCell }; //# sourceMappingURL=GridEditCell.js.map