@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
84 lines (78 loc) • 2.06 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 React, { memo } from 'react';
import Cell from '../cell';
import TextInput from '../text-input';
import Theme from '../theme';
/**
* Field 输入框
* @description 表单中的输入框组件。
* @description TODO 自定义输入项
* @description TODO 解决多行输入高度没对齐的问题
*/
const FieldTextInput = _ref => {
let {
// TODO 优化属性传递
style,
innerStyle,
title,
titleStyle,
titleTextStyle,
titleExtra,
valueStyle,
valueExtra,
contentStyle,
divider = true,
isLink = false,
onPressLink,
center = false,
arrowDirection = 'right',
required = false,
vertical = false,
// TextInput 属性
textAlign = 'right',
type,
textInputStyle,
textInputBordered,
...restProps
} = _ref;
if (vertical) {
textAlign = 'left';
type = 'textarea';
}
if (type === 'textarea') {
textAlign = 'left';
textInputBordered = true;
vertical = true;
}
const TOKENS = Theme.useThemeTokens();
const cellProps = {
style,
innerStyle,
title,
titleStyle,
titleTextStyle,
titleExtra,
valueExtra,
contentStyle,
divider,
isLink,
onPressLink,
center,
arrowDirection,
required,
vertical
};
return /*#__PURE__*/React.createElement(Cell, _extends({}, cellProps, {
valueStyle: [valueStyle, vertical ? {
marginTop: TOKENS.space_2
} : null],
value: /*#__PURE__*/React.createElement(TextInput, _extends({}, restProps, {
style: textInputStyle,
type: type,
bordered: textInputBordered,
textAlign: textAlign
}))
}));
};
export default /*#__PURE__*/memo(FieldTextInput);
//# sourceMappingURL=field-text-input.js.map