UNPKG

linkmore-design

Version:

🌈 πŸš€lmη»„δ»ΆεΊ“γ€‚πŸš€

67 lines (65 loc) β€’ 2.55 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _classnames = _interopRequireDefault(require("classnames")); var React = _interopRequireWildcard(require("react")); var _configProvider = require("../config-provider"); var _warning = _interopRequireDefault(require("../_util/warning")); const Divider = props => { const { getPrefixCls, direction } = React.useContext(_configProvider.ConfigContext); const { prefixCls: customizePrefixCls, type = 'horizontal', orientation = 'center', orientationMargin, className, children, dashed, plain, ...restProps } = props; const prefixCls = getPrefixCls('divider', customizePrefixCls); const orientationPrefix = orientation.length > 0 ? `-${orientation}` : orientation; const hasChildren = !!children; const hasCustomMarginLeft = orientation === 'left' && orientationMargin != null; const hasCustomMarginRight = orientation === 'right' && orientationMargin != null; const classString = (0, _classnames.default)(prefixCls, `${prefixCls}-${type}`, { [`${prefixCls}-with-text`]: hasChildren, [`${prefixCls}-with-text${orientationPrefix}`]: hasChildren, [`${prefixCls}-dashed`]: !!dashed, [`${prefixCls}-plain`]: !!plain, [`${prefixCls}-rtl`]: direction === 'rtl', [`${prefixCls}-no-default-orientation-margin-left`]: hasCustomMarginLeft, [`${prefixCls}-no-default-orientation-margin-right`]: hasCustomMarginRight }, className); const innerStyle = { ...(hasCustomMarginLeft && { marginLeft: orientationMargin }), ...(hasCustomMarginRight && { marginRight: orientationMargin }) }; // Warning children not work in vertical mode if (process.env.NODE_ENV !== 'production') { (0, _warning.default)(!children || type !== 'vertical', 'Divider', '`children` not working in `vertical` mode.'); } return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({ className: classString }, restProps, { role: "separator" }), children && type !== 'vertical' && /*#__PURE__*/React.createElement("span", { className: `${prefixCls}-inner-text`, style: innerStyle }, children)); }; var _default = Divider; exports.default = _default;