office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
44 lines • 2.55 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { css, autobind, BaseComponent } from '../../Utilities';
import { mergeStyles } from '../../Styling';
import { FocusZone, FocusZoneDirection } from '../../FocusZone';
import * as stylesImport from './OverflowSet.scss';
var styles = stylesImport;
var OverflowSet = /** @class */ (function (_super) {
tslib_1.__extends(OverflowSet, _super);
function OverflowSet() {
return _super !== null && _super.apply(this, arguments) || this;
}
OverflowSet.prototype.render = function () {
var _a = this.props, items = _a.items, overflowItems = _a.overflowItems, onRenderOverflowButton = _a.onRenderOverflowButton, className = _a.className, focusZoneProps = _a.focusZoneProps, _b = _a.vertical, vertical = _b === void 0 ? false : _b, _c = _a.role, role = _c === void 0 ? 'menubar' : _c;
return (React.createElement(FocusZone, tslib_1.__assign({}, focusZoneProps, { componentRef: this._resolveRef('_focusZone'), className: mergeStyles('ms-OverflowSet', styles.root, vertical && styles.rootVertical, className), direction: vertical ? FocusZoneDirection.vertical : FocusZoneDirection.horizontal, role: role }),
items && this._onRenderItems(items),
overflowItems && overflowItems.length > 0 && this._onRenderOverflowButtonWrapper(overflowItems)));
};
OverflowSet.prototype.focus = function () {
if (this._focusZone) {
this._focusZone.focus();
}
};
OverflowSet.prototype._onRenderItems = function (items) {
var _this = this;
return items.map(function (item, i) {
var wrapperDivProps = { className: css('ms-OverflowSet-item', styles.item) };
return (React.createElement("div", tslib_1.__assign({ key: item.key }, wrapperDivProps), _this.props.onRenderItem(item)));
});
};
OverflowSet.prototype._onRenderOverflowButtonWrapper = function (items) {
var wrapperDivProps = { className: css('ms-OverflowSet-overflowButton', styles.item) };
return (React.createElement("div", tslib_1.__assign({}, wrapperDivProps), this.props.onRenderOverflowButton(items)));
};
tslib_1.__decorate([
autobind
], OverflowSet.prototype, "_onRenderItems", null);
tslib_1.__decorate([
autobind
], OverflowSet.prototype, "_onRenderOverflowButtonWrapper", null);
return OverflowSet;
}(BaseComponent));
export { OverflowSet };
//# sourceMappingURL=OverflowSet.js.map