@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
69 lines (68 loc) • 2.04 kB
JavaScript
import React, { memo } from 'react';
import { Text, TouchableOpacity } from 'react-native';
import { varCreator as varCreatorButton } from "../button/style.js";
import { varCreator as varCreatorCell } from "../cell/style.js";
import Divider from "../divider/index.js";
import { getArrowOutline } from "../helpers/index.js";
import { usePersistFn } from "../hooks/index.js";
import Space from "../space/index.js";
import Theme from "../theme/index.js";
import SelectorInstance from "./selector-instance.js";
import { varCreator, styleCreator } from "./style.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const SelectorText = ({
theme,
title,
value,
options,
onChange,
arrowDirection,
divider = true,
head = true
}) => {
const [, STYLES] = Theme.useStyle({
varCreator,
styleCreator,
theme
});
const [CV_BUTTON] = Theme.useStyle({
varCreator: varCreatorButton
});
const [CV_CELL] = Theme.useStyle({
varCreator: varCreatorCell
});
const onPress = usePersistFn(() => {
SelectorInstance({
title,
options: options,
value,
onChange
}).catch(() => {});
});
const IconArrow = getArrowOutline(arrowDirection);
const textIndex = options.findIndex(op => op.value === value);
const text = options[textIndex].label;
return /*#__PURE__*/_jsx(TouchableOpacity, {
activeOpacity: CV_BUTTON.button_active_opacity,
onPress: onPress,
style: STYLES.text,
children: /*#__PURE__*/_jsxs(Space, {
direction: "horizontal",
align: "center",
head: head,
children: [divider ? /*#__PURE__*/_jsx(Divider, {
direction: "vertical"
}) : null, /*#__PURE__*/_jsx(Text, {
suppressHighlighting: true,
style: STYLES.text_text,
children: text
}), /*#__PURE__*/_jsx(IconArrow, {
size: CV_CELL.cell_icon_size,
color: CV_CELL.cell_icon_color
})]
})
});
};
export default /*#__PURE__*/memo(SelectorText);
//# sourceMappingURL=selector-text.js.map
;