UNPKG

@nutui/nutui-react

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

45 lines (44 loc) 2.5 kB
import { _ as _define_property } from "@swc/helpers/_/_define_property"; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties"; import React from "react"; import classNames from "classnames"; import { ComponentDefaults } from "../../utils/typings"; import { useRtl } from "../configprovider"; var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), { contentPosition: 'center', direction: 'horizontal' }); var classPrefix = "nut-divider"; export var Divider = function(props) { var _ref = _object_spread({}, defaultProps, props), children = _ref.children, contentPosition = _ref.contentPosition, style = _ref.style, className = _ref.className, direction = _ref.direction, rest = _object_without_properties(_ref, [ "children", "contentPosition", "style", "className", "direction" ]); var rtl = useRtl(); var _obj, _obj1; var classes = direction === 'horizontal' ? classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix), true), _define_property(_obj, "".concat(classPrefix, "-center"), children), _define_property(_obj, "".concat(classPrefix, "-left"), contentPosition === 'left'), _define_property(_obj, "".concat(classPrefix, "-right"), contentPosition === 'right'), _define_property(_obj, "".concat(classPrefix, "-rtl"), ([ 'left', 'right' ].includes(contentPosition) || children) && rtl), _obj)) : classNames((_obj1 = {}, _define_property(_obj1, "".concat(classPrefix), true), _define_property(_obj1, "".concat(classPrefix, "-vertical"), direction === 'vertical'), _obj1)); var getClassNames = function(direction) { return "".concat(classes.split(' ').map(function(item) { return "".concat(item, "-").concat(direction); }).join(' ')); }; return /*#__PURE__*/ React.createElement("div", _object_spread({ className: "".concat(classes, " ").concat(className || ''), style: style }, rest), direction === 'horizontal' && /*#__PURE__*/ React.createElement("div", { className: getClassNames('before'), style: style }), children, direction === 'horizontal' && /*#__PURE__*/ React.createElement("div", { className: getClassNames('after'), style: style })); }; Divider.displayName = 'NutDivider';