UNPKG

@brizy/ui

Version:
40 lines (39 loc) 1.84 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from "react"; import Col from "antd/lib/col"; const responsiveProps = (prop, key, defaultProperty) => { const defaultProps = { lg: { [key]: defaultProperty, }, md: { [key]: defaultProperty, }, xs: { [key]: defaultProperty, }, }; const data = Array.isArray(prop) ? prop : [prop]; data.forEach((el, index) => { const device = index === 0 ? "lg" : index === 1 ? "md" : "xs"; defaultProps[device][key] = el || 0; }); return defaultProps; }; export const LayoutSection = (_a) => { var { span = 24, push = 0, pull = 0, children } = _a, extra = __rest(_a, ["span", "push", "pull", "children"]); const spanResponsive = responsiveProps(span, "span", 24); const pushResponsive = responsiveProps(push, "push", 0); const pullResponsive = responsiveProps(pull, "pull", 0); return (React.createElement(Col, Object.assign({ lg: Object.assign(Object.assign(Object.assign({}, spanResponsive["lg"]), pushResponsive["lg"]), pullResponsive["lg"]), md: Object.assign(Object.assign(Object.assign({}, spanResponsive["md"]), pushResponsive["md"]), pullResponsive["md"]), xs: Object.assign(Object.assign(Object.assign({}, spanResponsive["xs"]), pushResponsive["xs"]), pullResponsive["xs"]) }, extra), children)); };