UNPKG

@arche-mc2/arche-controls

Version:

We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get

48 lines 2.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var classNames = require("classnames"); var assign = require("object-assign"); var UpGridContext_1 = require("./UpGridContext"); var RowRenderer = function (props) { var prefixCls = props.prefixCls, justify = props.justify, align = props.align, className = props.className, style = props.style, children = props.children, type = props.type, gutter = props.gutter, rowSpacing = props.rowSpacing, fullRowLayout = props.fullRowLayout, others = tslib_1.__rest(props, ["prefixCls", "justify", "align", "className", "style", "children", "type", "gutter", "rowSpacing", "fullRowLayout"]); var getRowStyle = function () { return gutter > 0 ? assign({}, { marginLeft: gutter / -2, marginRight: gutter / -2 }, style) : style; }; var getClasses = function () { var _a; return classNames((_a = {}, _a[prefixCls] = type == 'float', _a[prefixCls + "-flex"] = type == 'flex', _a[prefixCls + "-flex-" + justify] = type == 'flex' && justify, _a[prefixCls + "-flex-" + align] = type == 'flex' && align, _a[prefixCls + "-flex-full"] = fullRowLayout, _a), className); }; var cols = children; if (rowSpacing > 0 || type != 'float') { cols = React.Children.map(children, function (row) { if (!row) { return null; } if (row.props) { return React.cloneElement(row, { rowSpacing: row.props.rowSpacing == 0 ? rowSpacing : row.props.gutter, type: row.props.type ? row.props.type : row.props.type }); } return row; }); } return React.createElement("div", tslib_1.__assign({}, others, { className: getClasses(), style: getRowStyle() }), cols); }; var UpRow = function (_a) { var _b = _a.gutter, gutter = _b === void 0 ? 0 : _b, _c = _a.rowSpacing, rowSpacing = _c === void 0 ? 0 : _c, _d = _a.type, type = _d === void 0 ? 'flex' : _d, _e = _a.prefixCls, prefixCls = _e === void 0 ? 'up-row' : _e, rest = tslib_1.__rest(_a, ["gutter", "rowSpacing", "type", "prefixCls"]); return (React.createElement(UpGridContext_1.UpGridConsumer, null, function (value) { return React.createElement(RowRenderer, tslib_1.__assign({ fullRowLayout: value.fullRowLayout, gutter: gutter || value.gutter, rowSpacing: rowSpacing || value.rowSpacing, type: type || value.type, prefixCls: prefixCls }, rest)); })); }; exports.default = UpRow; //# sourceMappingURL=UpRow.js.map