@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
51 lines • 3.19 kB
JavaScript
;
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 ColRenderer = function (props) {
var gutter = props.gutter, xs = props.xs, sm = props.sm, md = props.md, lg = props.lg, xl = props.xl, prefixCls = props.prefixCls, span = props.span, order = props.order, offset = props.offset, push = props.push, pull = props.pull, className = props.className, style = props.style, children = props.children, rowSpacing = props.rowSpacing, others = tslib_1.__rest(props, ["gutter", "xs", "sm", "md", "lg", "xl", "prefixCls", "span", "order", "offset", "push", "pull", "className", "style", "children", "rowSpacing"]);
var getClasses = function () {
var _a;
var sizeClassObj = {};
['xs', 'sm', 'md', 'lg', 'xl'].forEach(function (size) {
var _a;
var sizeProps = {};
if (typeof props[size] === 'number') {
sizeProps.span = props[size];
}
else if (typeof props[size] === 'object') {
sizeProps = props[size] || {};
}
sizeClassObj = assign({}, sizeClassObj, (_a = {},
_a[prefixCls + "-" + size + "-" + sizeProps.span] = sizeProps.span !== undefined,
_a[prefixCls + "-" + size + "-order-" + sizeProps.order] = sizeProps.order || sizeProps.order === 0,
_a[prefixCls + "-" + size + "-offset-" + sizeProps.offset] = sizeProps.offset || sizeProps.offset === 0,
_a[prefixCls + "-" + size + "-push-" + sizeProps.push] = sizeProps.push || sizeProps.push === 0,
_a[prefixCls + "-" + size + "-pull-" + sizeProps.pull] = sizeProps.pull || sizeProps.pull === 0,
_a));
});
return classNames((_a = {},
_a[prefixCls + "-" + span] = span !== undefined,
_a[prefixCls + "-order-" + order] = order,
_a[prefixCls + "-offset-" + offset] = offset,
_a[prefixCls + "-push-" + push] = push,
_a[prefixCls + "-pull-" + pull] = pull,
_a), className, sizeClassObj);
};
var getStyle = function () {
if (gutter > 0 || rowSpacing > 0) {
return tslib_1.__assign({ paddingLeft: gutter / 2, paddingRight: gutter / 2, marginBottom: rowSpacing }, style);
}
return style;
};
return React.createElement("div", tslib_1.__assign({ style: getStyle() }, others, { className: getClasses() }), children);
};
var UpCol = function (_a) {
var _b = _a.prefixCls, prefixCls = _b === void 0 ? 'up-col' : _b, rowSpacing = _a.rowSpacing, rest = tslib_1.__rest(_a, ["prefixCls", "rowSpacing"]);
return (React.createElement(UpGridContext_1.UpGridConsumer, null, function (value) { return React.createElement(ColRenderer, tslib_1.__assign({ gutter: value.gutter, rowSpacing: rowSpacing || value.rowSpacing, prefixCls: prefixCls }, rest)); }));
};
exports.default = UpCol;
//# sourceMappingURL=UpCol.js.map