@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
57 lines (54 loc) • 1.74 kB
JavaScript
import isNil from 'lodash/isNil';
import React, { memo } from 'react';
import { View, TouchableWithoutFeedback } from 'react-native';
import Divider from "../divider/index.js";
import { renderTextLikeJSX } from "../helpers/index.js";
import Theme from "../theme/index.js";
import { varCreator, styleCreator } from "./style.js";
/**
* CellGroup 单元格组
* @description 一组单元格,可以设置一个标题。
*/
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
const CellGroup = ({
children,
theme,
title,
extra,
style,
titleTextStyle,
bodyStyle,
bodyTopDivider = false,
bodyBottomDivider = false,
onPressTitle,
onPressTitleText
}) => {
const [, STYLES] = Theme.useStyle({
varCreator,
styleCreator,
theme
});
/** 标题 可能是自定义 JSX */
const titleJSX = renderTextLikeJSX(title, [STYLES.group_title_text, titleTextStyle], {
onPress: onPressTitleText
});
const groupNameJSX = /*#__PURE__*/_jsxs(View, {
style: [STYLES.group_title, style],
children: [titleJSX, extra]
});
const bodyJSX = /*#__PURE__*/_jsxs(_Fragment, {
children: [bodyTopDivider ? /*#__PURE__*/_jsx(Divider, {}) : null, children, bodyBottomDivider ? /*#__PURE__*/_jsx(Divider, {}) : null]
});
return /*#__PURE__*/_jsxs(_Fragment, {
children: [titleJSX || !isNil(extra) ? !isNil(onPressTitle) ? /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
onPress: onPressTitle,
children: groupNameJSX
}) : groupNameJSX : null, bodyStyle ? /*#__PURE__*/_jsx(View, {
style: bodyStyle,
children: bodyJSX
}) : bodyJSX]
});
};
export default /*#__PURE__*/memo(CellGroup);
//# sourceMappingURL=cell-group.js.map
;