office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
61 lines • 3.19 kB
JavaScript
define(["require", "exports", "tslib", "react", "../../Utilities", "../../Button"], function (require, exports, tslib_1, React, Utilities_1, Button_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GridCell = /** @class */ (function (_super) {
tslib_1.__extends(GridCell, _super);
function GridCell() {
return _super !== null && _super.apply(this, arguments) || this;
}
GridCell.prototype.render = function () {
var _a = this.props, item = _a.item, id = _a.id, className = _a.className, role = _a.role, selected = _a.selected, disabled = _a.disabled, onRenderItem = _a.onRenderItem, cellDisabledStyle = _a.cellDisabledStyle, cellIsSelectedStyle = _a.cellIsSelectedStyle, index = _a.index, label = _a.label, getClassNames = _a.getClassNames;
return (React.createElement(Button_1.CommandButton, { id: id + '-item' + index, "data-index": index, "data-is-focusable": true, disabled: disabled, className: Utilities_1.css(className, (_b = {},
_b['' + cellIsSelectedStyle] = selected,
_b['' + cellDisabledStyle] = disabled,
_b)), onClick: this._onClick, onMouseEnter: this._onMouseEnter, onMouseLeave: this._onMouseLeave, onFocus: this._onFocus, role: role, "aria-selected": selected, ariaLabel: label, title: label, getClassNames: getClassNames }, onRenderItem(item)));
var _b;
};
GridCell.prototype._onClick = function () {
var _a = this.props, onClick = _a.onClick, disabled = _a.disabled, item = _a.item;
if (onClick && !disabled) {
onClick(item);
}
};
GridCell.prototype._onMouseEnter = function () {
var _a = this.props, onHover = _a.onHover, disabled = _a.disabled, item = _a.item;
if (onHover && !disabled) {
onHover(item);
}
};
GridCell.prototype._onMouseLeave = function () {
var _a = this.props, onHover = _a.onHover, disabled = _a.disabled;
if (onHover && !disabled) {
onHover();
}
};
GridCell.prototype._onFocus = function () {
var _a = this.props, onFocus = _a.onFocus, disabled = _a.disabled, item = _a.item;
if (onFocus && !disabled) {
onFocus(item);
}
};
GridCell.defaultProps = {
disabled: false,
id: Utilities_1.getId('gridCell')
};
tslib_1.__decorate([
Utilities_1.autobind
], GridCell.prototype, "_onClick", null);
tslib_1.__decorate([
Utilities_1.autobind
], GridCell.prototype, "_onMouseEnter", null);
tslib_1.__decorate([
Utilities_1.autobind
], GridCell.prototype, "_onMouseLeave", null);
tslib_1.__decorate([
Utilities_1.autobind
], GridCell.prototype, "_onFocus", null);
return GridCell;
}(React.Component));
exports.GridCell = GridCell;
});
//# sourceMappingURL=GridCell.js.map