office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
34 lines • 2.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Utilities_1 = require("../../Utilities");
var FocusZone_1 = require("../../FocusZone");
var getClassNames = Utilities_1.classNamesFunction();
var GridBase = /** @class */ (function (_super) {
tslib_1.__extends(GridBase, _super);
function GridBase(props) {
var _this = _super.call(this, props) || this;
_this._id = Utilities_1.getId();
return _this;
}
GridBase.prototype.render = function () {
var _this = this;
var _a = this.props, items = _a.items, columnCount = _a.columnCount, onRenderItem = _a.onRenderItem, positionInSet = _a.positionInSet, setSize = _a.setSize, styles = _a.styles;
var htmlProps = Utilities_1.getNativeProps(this.props, Utilities_1.htmlElementProperties, ['onBlur, aria-posinset, aria-setsize']);
var classNames = getClassNames(styles, { theme: this.props.theme });
// Array to store the cells in the correct row index
var rowsOfItems = Utilities_1.toMatrix(items, columnCount);
var content = (React.createElement("table", tslib_1.__assign({}, htmlProps, { "aria-posinset": positionInSet, "aria-setsize": setSize, id: this._id, role: 'grid', className: classNames.root }),
React.createElement("tbody", null, rowsOfItems.map(function (rows, rowIndex) {
return (React.createElement("tr", { role: 'row', key: _this._id + '-' + rowIndex + '-row' }, rows.map(function (cell, cellIndex) {
return (React.createElement("td", { role: 'presentation', key: _this._id + '-' + cellIndex + '-cell', className: classNames.tableCell }, onRenderItem(cell, cellIndex)));
})));
}))));
// Create the table/grid
return this.props.doNotContainWithinFocusZone ? (content) : (React.createElement(FocusZone_1.FocusZone, { isCircularNavigation: this.props.shouldFocusCircularNavigate, className: classNames.focusedContainer, onBlur: this.props.onBlur }, content));
};
return GridBase;
}(Utilities_1.BaseComponent));
exports.GridBase = GridBase;
//# sourceMappingURL=Grid.base.js.map
;