var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define(["require", "exports", 'react', '../../utilities/css', '../../utilities/object'], function (require, exports, React, css_1, object_1) {
    "use strict";
    var DetailsRowFields = (function (_super) {
        __extends(DetailsRowFields, _super);
        function DetailsRowFields(props) {
            _super.call(this);
            this.state = this._getState(props);
        }
        DetailsRowFields.prototype.shouldComponentUpdate = function (newProps) {
            return !object_1.shallowCompare(this.props, newProps);
        };
        DetailsRowFields.prototype.componentWillReceiveProps = function (newProps) {
            this.setState(this._getState(newProps));
        };
        DetailsRowFields.prototype.render = function () {
            var columns = this.props.columns;
            var cellContent = this.state.cellContent;
            return (React.createElement("div", {className: 'ms-DetailsRow-fields', "data-automationid": 'DetailsRowFields'}, columns.map(function (column, columnIndex) { return (React.createElement("div", {key: columnIndex, role: column.isRowHeader ? 'rowheader' : '', className: css_1.css('ms-DetailsRow-cell', column.className, {
                'is-multiline': column.isMultiline
            }), style: { width: column.calculatedWidth }, "data-automationid": 'DetailsRowCell', "data-automation-key": column.key}, cellContent[columnIndex])); })));
        };
        DetailsRowFields.prototype._getState = function (props) {
            var item = props.item, itemIndex = props.itemIndex;
            return {
                cellContent: props.columns.map(function (column) {
                    var cellContent;
                    try {
                        cellContent = column.onRender ? column.onRender(item, itemIndex) : (String(item[column.fieldName] || ''));
                    }
                    catch (e) { }
                    return cellContent;
                })
            };
        };
        return DetailsRowFields;
    }(React.Component));
    exports.DetailsRowFields = DetailsRowFields;
});
