"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var WidgetBase_1 = require("@dojo/framework/core/WidgetBase");
var vdom_1 = require("@dojo/framework/core/vdom");
var I18n_1 = require("@dojo/framework/core/mixins/I18n");
var Themed_1 = require("@dojo/framework/core/mixins/Themed");
var Cell_1 = require("./Cell");
var fixedCss = require("./styles/row.m.css");
var css = require("../theme/default/grid-row.m.css");
var Row = /** @class */ (function (_super) {
    tslib_1.__extends(Row, _super);
    function Row() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Row.prototype._onRowSelect = function (event) {
        var onRowSelect = this.properties.onRowSelect;
        var type = event.ctrlKey || event.metaKey ? 'multi' : 'single';
        onRowSelect && onRowSelect(type);
    };
    Row.prototype.render = function () {
        var _this = this;
        var _a = this.properties, i18nBundle = _a.i18nBundle, item = _a.item, columnConfig = _a.columnConfig, id = _a.id, theme = _a.theme, classes = _a.classes, columnWidths = _a.columnWidths, onRowSelect = _a.onRowSelect, selected = _a.selected;
        var columns = columnConfig.map(function (config) {
            var value = "" + item[config.id];
            if (config.renderer) {
                value = config.renderer({ value: value });
            }
            return vdom_1.w(Cell_1.default, {
                i18nBundle: i18nBundle,
                theme: theme,
                key: config.id,
                classes: classes,
                updater: function (updatedValue) {
                    _this.properties.updater(id, config.id, updatedValue);
                },
                value: value,
                editable: config.editable,
                rawValue: "" + item[config.id],
                width: columnWidths ? columnWidths[config.id] : undefined
            });
        }, []);
        return vdom_1.v('div', {
            key: 'root',
            classes: [
                this.theme(css.root),
                selected && this.theme(css.selected),
                fixedCss.rootFixed,
                onRowSelect && this.theme(css.selectable)
            ],
            role: 'row',
            onclick: onRowSelect ? this._onRowSelect : undefined,
            'aria-rowindex': "" + (id + 1)
        }, columns);
    };
    Row = tslib_1.__decorate([
        Themed_1.theme(css)
    ], Row);
    return Row;
}(I18n_1.default(Themed_1.default(WidgetBase_1.default))));
exports.default = Row;

/*# sourceMappingURL=Row.js.map*/