UNPKG

@fruits-chain/react-native-xiaoshu

Version:
68 lines (66 loc) • 2 kB
"use strict"; import isNil from 'lodash/isNil'; import React, { memo } from 'react'; import { View, Text } from 'react-native'; import { getDefaultValue } from "../helpers/index.js"; import Theme from "../theme/index.js"; import DividerLine from "./divider-line.js"; import DividerLineDashed from "./divider-line-dashed.js"; import { varCreator, styleCreator } from "./style.js"; /** * Divider 分割线 * @description 用于将内容分隔为多个区域。 */ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; const Divider = ({ children, style, theme, textStyle, type = 'light', direction = 'horizontal', dashed = false, color, contentPosition = 'center', ...restProps }) => { const [CV, STYLES] = Theme.useStyle({ varCreator, styleCreator, theme }); const isVertical = direction === 'vertical'; const Line = dashed ? DividerLineDashed : DividerLine; color = getDefaultValue(color, type === 'dark' ? CV.divider_color_dark : CV.divider_color_light); return /*#__PURE__*/_jsx(View, { ...restProps, style: [STYLES.divider, isVertical ? STYLES.divider_vertical : null, style], children: isVertical ? /*#__PURE__*/_jsx(Line, { theme: theme, color: color, position: "center", direction: direction }) : !isNil(children) ? /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(Line, { theme: theme, color: color, position: "left", adaptive: contentPosition !== 'left' }), /*#__PURE__*/_jsx(Text, { style: [STYLES.text, textStyle], children: children }), /*#__PURE__*/_jsx(Line, { theme: theme, color: color, position: "right", adaptive: contentPosition !== 'right' })] }) : /*#__PURE__*/_jsx(Line, { theme: theme, color: color, position: "center" }) }); }; export default /*#__PURE__*/memo(Divider); //# sourceMappingURL=divider.js.map