UNPKG

@yandex/ui

Version:

Yandex UI components

38 lines (37 loc) 1.86 kB
import { __assign, __rest } from "tslib"; import React from 'react'; import { cn } from '@bem-react/classname'; export var cnSpacer = 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 */ export 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 = __rest(_a, ["all", "vertical", "horizontal", "top", "bottom", "left", "right", "innerRef", "style", "className", "children", "as"]); return (React.createElement(Component, __assign({}, props, { ref: innerRef, className: cnSpacer(null, [className]), style: __assign(__assign({}, getSpace({ all: all, vertical: vertical, horizontal: horizontal, top: top, left: left, bottom: bottom, right: right })), style) }), children)); }; Spacer.displayName = cnSpacer();