"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Utilities_1 = require("../../Utilities");
var DetailsRow_styles_1 = require("./DetailsRow.styles");
var getCellText = function (item, column) {
    var value = item && column && column.fieldName ? item[column.fieldName] : '';
    if (value === null || value === undefined) {
        value = '';
    }
    return value;
};
/**
 * Component for rendering a row's cells in a {@link DetailsList}.
 *
 * {@docCategory DetailsList}
 */
var DetailsRowFields = /** @class */ (function (_super) {
    tslib_1.__extends(DetailsRowFields, _super);
    function DetailsRowFields() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DetailsRowFields.prototype.render = function () {
        var _a = this.props, columns = _a.columns, columnStartIndex = _a.columnStartIndex, shimmer = _a.shimmer, rowClassNames = _a.rowClassNames, _b = _a.cellStyleProps, cellStyleProps = _b === void 0 ? DetailsRow_styles_1.DEFAULT_CELL_STYLE_PROPS : _b, item = _a.item, itemIndex = _a.itemIndex, onRenderItemColumn = _a.onRenderItemColumn, cellsByColumn = _a.cellsByColumn;
        return (React.createElement("div", { className: rowClassNames.fields, "data-automationid": "DetailsRowFields", role: "presentation" }, columns.map(function (column, columnIndex) {
            var width = typeof column.calculatedWidth === 'undefined'
                ? 'auto'
                : column.calculatedWidth +
                    cellStyleProps.cellLeftPadding +
                    cellStyleProps.cellRightPadding +
                    (column.isPadded ? cellStyleProps.cellExtraRightPadding : 0);
            var _a = column.onRender, onRender = _a === void 0 ? onRenderItemColumn : _a;
            var cellContentsRender = cellsByColumn && column.key in cellsByColumn
                ? cellsByColumn[column.key]
                : onRender && !shimmer
                    ? onRender(item, itemIndex, column)
                    : getCellText(item, column);
            return (React.createElement("div", { key: columnIndex, role: column.isRowHeader ? 'rowheader' : 'gridcell', "aria-colindex": columnIndex + columnStartIndex + 1, className: Utilities_1.css(column.className, column.isMultiline && rowClassNames.isMultiline, column.isRowHeader && rowClassNames.isRowHeader, column.isIconOnly && shimmer && rowClassNames.shimmerIconPlaceholder, shimmer && rowClassNames.shimmer, rowClassNames.cell, column.isPadded ? rowClassNames.cellPadded : rowClassNames.cellUnpadded), style: { width: width }, "data-automationid": "DetailsRowCell", "data-automation-key": column.key }, cellContentsRender));
        })));
    };
    return DetailsRowFields;
}(React.PureComponent));
exports.DetailsRowFields = DetailsRowFields;
//# sourceMappingURL=DetailsRowFields.js.map