@uifabric/experiments
Version:
Experimental React components for building experiences for Office 365.
55 lines • 2.36 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { mergeStyles } from 'office-ui-fabric-react/lib/Styling';
import { getNativeProps, divProperties } from 'office-ui-fabric-react/lib/Utilities';
var LayoutGroup = /** @class */ (function (_super) {
tslib_1.__extends(LayoutGroup, _super);
function LayoutGroup() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._getJustify = function (justify) {
if (justify === 'end') {
return 'flex-end';
}
else if (justify === 'center') {
return 'center';
}
else {
return 'flex-start';
}
};
return _this;
}
LayoutGroup.prototype.render = function () {
var _a = this.props, children = _a.children, direction = _a.direction, layoutGap = _a.layoutGap, justify = _a.justify;
var divProps = getNativeProps(this.props, divProperties);
var numberOfChildren = React.Children.count(children);
var group = React.Children.map(children, function (child, i) {
var isLastChild = i === numberOfChildren - 1;
// Render individual item
return (React.createElement("div", { className: mergeStyles('ms-LayoutGroup-item', direction === 'horizontal' &&
!isLastChild && {
marginRight: layoutGap + 'px'
}, direction === 'vertical' &&
!isLastChild && {
marginBottom: layoutGap + 'px'
}, justify === 'fill' && {
flexBasis: '0',
flexGrow: 1
}) }, child));
});
// Render all items
return (React.createElement("div", tslib_1.__assign({}, divProps, { className: mergeStyles('ms-LayoutGroup', {
display: 'flex',
flexDirection: direction === 'horizontal' ? 'row' : 'column',
justifyContent: this._getJustify(justify)
}) }), group));
};
LayoutGroup.defaultProps = {
layoutGap: 8,
direction: 'vertical',
justify: 'start'
};
return LayoutGroup;
}(React.Component));
export { LayoutGroup };
//# sourceMappingURL=LayoutGroup.js.map