UNPKG

@fruits-chain/react-native-xiaoshu

Version:
47 lines (42 loc) • 1.71 kB
import React, { memo } from 'react'; import { View } from 'react-native'; import { formatDate } from '../date-picker-view/helper'; import { renderTextLikeJSX, getDefaultValue } from '../helpers'; import Locale from '../locale'; import Theme from '../theme'; import { useDescription } from './context'; import Description from './description'; import { varCreator, styleCreator } from './style'; const DescriptionDateRange = _ref => { let { text, mode = 'Y-m', split, bold = false, color, contentTextStyle, ...restProps } = _ref; const start = formatDate(mode, text[0]); const end = formatDate(mode, text[1]); const locale = Locale.useLocale().DescriptionDateRange; const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const STYLES = Theme.createStyle(CV, styleCreator); const descriptionContext = useDescription(); const _contentTextStyle = getDefaultValue(contentTextStyle, descriptionContext.contentTextStyle); const _size = getDefaultValue(restProps.size, descriptionContext.size); const textSizeStyle = STYLES[`size_${_size}_text`]; const textStyles = [STYLES.content_text, textSizeStyle, bold ? { fontWeight: 'bold' } : null, color ? { color } : null, _contentTextStyle]; const line1JSX = renderTextLikeJSX([start, split || locale.split].join(' '), textStyles); const line2JSX = renderTextLikeJSX(end, textStyles); return /*#__PURE__*/React.createElement(Description, restProps, /*#__PURE__*/React.createElement(View, { style: STYLES.content_date_range }, line1JSX, line2JSX)); }; export default /*#__PURE__*/memo(DescriptionDateRange); //# sourceMappingURL=description-date-range.js.map