UNPKG

@yandex/ui

Version:

Yandex UI components

42 lines (41 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Spacer = exports.cnSpacer = void 0; var tslib_1 = require("tslib"); var react_1 = tslib_1.__importDefault(require("react")); var classname_1 = require("@bem-react/classname"); exports.cnSpacer = classname_1.cn('Spacer'); var getSpace = function (_a) { var all = _a.all, vertical = _a.vertical, horizontal = _a.horizontal, top = _a.top, left = _a.left, bottom = _a.bottom, right = _a.right; if (all !== undefined) { return { padding: all, }; } if (vertical !== undefined || horizontal !== undefined) { return { paddingTop: vertical, paddingBottom: vertical, paddingLeft: horizontal, paddingRight: horizontal, }; } if (top !== undefined || left !== undefined || bottom !== undefined || right !== undefined) { return { paddingTop: top, paddingBottom: bottom, paddingLeft: left, paddingRight: right, }; } }; /** * Компонент который вставляет своих детей с заданным смещением. * @param {SpacerProps} props */ var Spacer = function (_a) { var all = _a.all, vertical = _a.vertical, horizontal = _a.horizontal, top = _a.top, bottom = _a.bottom, left = _a.left, right = _a.right, innerRef = _a.innerRef, style = _a.style, className = _a.className, children = _a.children, _b = _a.as, Component = _b === void 0 ? 'div' : _b, props = tslib_1.__rest(_a, ["all", "vertical", "horizontal", "top", "bottom", "left", "right", "innerRef", "style", "className", "children", "as"]); return (react_1.default.createElement(Component, tslib_1.__assign({}, props, { ref: innerRef, className: exports.cnSpacer(null, [className]), style: tslib_1.__assign(tslib_1.__assign({}, getSpace({ all: all, vertical: vertical, horizontal: horizontal, top: top, left: left, bottom: bottom, right: right })), style) }), children)); }; exports.Spacer = Spacer; exports.Spacer.displayName = exports.cnSpacer();