UNPKG

preact-arco-design

Version:

Arco Design React UI Library.

37 lines (33 loc) 1.46 kB
import React, { useContext, forwardRef } from "preact/compat"; import cs from "../_util/classNames"; import { ConfigContext } from "../ConfigProvider"; import useMergeProps from "../_util/hooks/useMergeProps"; var defaultProps = { type: 'horizontal', orientation: 'center' }; function Divider(baseProps, ref) { var _a; var _b = useContext(ConfigContext), getPrefixCls = _b.getPrefixCls, componentConfig = _b.componentConfig; var props = useMergeProps(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Divider); var children = props.children, style = props.style, className = props.className, type = props.type, orientation = props.orientation; var prefixCls = getPrefixCls('divider'); var classNames = cs(prefixCls, "".concat(prefixCls, "-").concat(type), (_a = {}, _a["".concat(prefixCls, "-with-text")] = children, _a["".concat(prefixCls, "-with-text-").concat(orientation)] = children && orientation, _a), className); return React.createElement("div", { role: "separator", ref: ref, className: classNames, style: style }, children && type === 'horizontal' ? React.createElement("span", { className: "".concat(prefixCls, "-text ").concat(prefixCls, "-text-").concat(orientation) }, children) : null); } var DividerComponent = forwardRef(Divider); DividerComponent.displayName = 'Divider'; export default DividerComponent;