@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
39 lines (35 loc) • 1.49 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import isNil from 'lodash/isNil';
import React, { useMemo, memo } from 'react';
import Cell from '../cell';
import { getDefaultValue } from '../helpers';
import { varCreator as varCreatorTextInput } from '../text-input/style';
import Theme from '../theme';
/**
* 输入框 纯文字方式
*/
const FieldText = _ref => {
let {
placeholder,
placeholderTextColor,
value,
valueTextStyle,
...restProps
} = _ref;
const hasValue = !isNil(value);
const text = hasValue ? value : placeholder;
const TOKENS = Theme.useThemeTokens();
const CV_TEXT_INPUT = Theme.createVar(TOKENS, varCreatorTextInput); // 修正数据
placeholderTextColor = getDefaultValue(placeholderTextColor, CV_TEXT_INPUT.text_input_placeholder_text_color);
const valueTextStyles = useMemo(() => {
return [valueTextStyle, !hasValue ? {
color: placeholderTextColor
} : null];
}, [valueTextStyle, hasValue, placeholderTextColor]);
return /*#__PURE__*/React.createElement(Cell, _extends({}, restProps, {
value: text,
valueTextStyle: valueTextStyles
}));
};
export default /*#__PURE__*/memo(FieldText);
//# sourceMappingURL=field-text.js.map