UNPKG

@fruits-chain/react-native-xiaoshu

Version:
61 lines (59 loc) • 1.98 kB
import React, { memo } from 'react'; import { Text, TouchableOpacity } from 'react-native'; import { varCreator as varCreatorButton } from '../button/style'; import { varCreator as varCreatorCell } from '../cell/style'; import Divider from '../divider'; import { usePersistFn } from '../hooks'; import { getArrowOutline } from '../icon/helper/arrow'; import Space from '../space'; import Theme from '../theme'; import SelectorFn from './selector-fn'; import { varCreator } from './style'; import { styleCreator } from './style.text'; const SelectorText = _ref => { let { title, value, options, onChange, arrowDirection, divider = true, head = true } = _ref; const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const CV_BUTTON = Theme.createVar(TOKENS, varCreatorButton); const CV_CELL = Theme.createVar(TOKENS, varCreatorCell); const STYLES = Theme.createStyle(CV, styleCreator, TOKENS); const onPress = usePersistFn(() => { SelectorFn({ title, options: options, value, onChange }); }); const IconArrow = getArrowOutline(arrowDirection); const textIndex = options.findIndex(op => op.value === value); const text = options[textIndex].label; return /*#__PURE__*/React.createElement(TouchableOpacity, { activeOpacity: CV_BUTTON.button_active_opacity, onPress: onPress, style: STYLES.text }, /*#__PURE__*/React.createElement(Space, { direction: "horizontal", align: "center", gapVertical: 0, head: head }, divider ? /*#__PURE__*/React.createElement(Divider, { direction: "vertical" }) : null, /*#__PURE__*/React.createElement(Text, { suppressHighlighting: true, style: STYLES.text_text }, text), /*#__PURE__*/React.createElement(IconArrow, { size: CV_CELL.cell_icon_size, color: CV_CELL.cell_icon_color }))); }; export default /*#__PURE__*/memo(SelectorText); //# sourceMappingURL=selector-text.js.map