UNPKG

lole-ui

Version:

React UI Component which like a love letter

48 lines (47 loc) 2.96 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; 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 classNames from "classnames"; import { GlobalReviewContext } from "../GlobalReview/global_review"; var Divider = function (props) { var _a; var direction = React.useContext(GlobalReviewContext).direction; var _b = props.type, type = _b === void 0 ? 'horizontal' : _b, _c = props.orientation, orientation = _c === void 0 ? 'center' : _c, orientationMargin = props.orientationMargin, className = props.className, children = props.children, dashed = props.dashed, plain = props.plain, restProps = __rest(props, ["type", "orientation", "orientationMargin", "className", "children", "dashed", "plain"]); var prefixCls = 'xiOn-divider'; var orientationPrefix = orientation.length > 0 ? "-".concat(orientation) : orientation; var hasChildren = !!children; var hasCustomMarginLeft = orientation === 'left' && orientationMargin != null; var hasCustomMarginRight = orientation === 'right' && orientationMargin != null; var classString = classNames(prefixCls, "".concat(prefixCls, "-").concat(type), (_a = {}, _a["".concat(prefixCls, "-with-text")] = hasChildren, _a["".concat(prefixCls, "-with-text").concat(orientationPrefix)] = hasChildren, _a["".concat(prefixCls, "-dashed")] = !!dashed, _a["".concat(prefixCls, "-plain")] = !!plain, _a["".concat(prefixCls, "-rtl")] = direction === 'rtl', _a["".concat(prefixCls, "-no-default-orientation-margin-left")] = hasCustomMarginLeft, _a["".concat(prefixCls, "-no-default-orientation-margin-right")] = hasCustomMarginRight, _a), className); var innerStyle = __assign(__assign({}, (hasCustomMarginLeft && { marginLeft: orientationMargin })), (hasCustomMarginRight && { marginRight: orientationMargin })); return (React.createElement("div", __assign({ className: classString }, restProps, { role: "separator" }), children && (React.createElement("span", { className: "".concat(prefixCls, "-inner-text"), style: innerStyle }, children)))); }; export default Divider;