UNPKG

@up-group-ui/react-controls

Version:
41 lines 2.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UpGrid = void 0; var tslib_1 = require("tslib"); var jsx_runtime_1 = require("react/jsx-runtime"); var React = (0, tslib_1.__importStar)(require("react")); var theming_1 = (0, tslib_1.__importDefault)(require("../../../Common/theming")); var styles_1 = require("./styles"); var withTheme_1 = (0, tslib_1.__importDefault)(require("../../../Common/theming/withTheme")); var classnames_1 = (0, tslib_1.__importDefault)(require("classnames")); var UpGridContext_1 = require("./UpGridContext"); var UpGrid = function (_a) { var _b = _a.gutter, gutter = _b === void 0 ? 0 : _b, _c = _a.fullRowLayout, fullRowLayout = _c === void 0 ? false : _c, _d = _a.rowSpacing, rowSpacing = _d === void 0 ? 0 : _d, _e = _a.type, type = _e === void 0 ? 'flex' : _e, _f = _a.theme, theme = _f === void 0 ? theming_1.default : _f, rest = (0, tslib_1.__rest)(_a, ["gutter", "fullRowLayout", "rowSpacing", "type", "theme"]); var children = rest.children, className = rest.className, style = rest.style; var rows = children; var _gutter = gutter != null ? gutter : theme.gridGutter != null ? theme.gridGutter : 0; var _rowSpacing = rowSpacing != null ? rowSpacing : theme.gridRowSpacing != null ? theme.gridRowSpacing : 0; if (_gutter > 0 || type != 'float') { rows = React.Children.map(children, function (row, index) { if (!row) { return null; } if (row.props) { return ((0, jsx_runtime_1.jsx)(React.Fragment, { children: React.cloneElement(row, { gutter: row.props.gutter == 0 ? _gutter : row.props.gutter, type: row.props.type, }) }, index)); } return row; }); } return ((0, jsx_runtime_1.jsx)(UpGridContext_1.UpGridProvider, (0, tslib_1.__assign)({ value: { gutter: _gutter, rowSpacing: _rowSpacing, type: type, fullRowLayout: fullRowLayout, } }, { children: (0, jsx_runtime_1.jsx)("div", (0, tslib_1.__assign)({ style: style, className: (0, classnames_1.default)(className, styles_1.GridStyles) }, { children: rows }), void 0) }), void 0)); }; exports.UpGrid = UpGrid; exports.default = (0, withTheme_1.default)(UpGrid); //# sourceMappingURL=UpGrid.js.map