@sishuguojixuefu/react-native-form
Version:
47 lines • 2.38 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const antd_mobile_rn_1 = require("@sishuguojixuefu/antd-mobile-rn");
const lodash_omit_1 = __importDefault(require("lodash.omit"));
const getFieldDecorator_1 = __importDefault(require("../utils/getFieldDecorator"));
const TextareaWrap_1 = __importDefault(require("./helper/TextareaWrap"));
class Textarea extends react_1.Component {
constructor() {
super(...arguments);
this.inputed = 0;
this._onChange = (value) => {
const { onChange } = this.props;
this.inputed = value ? value.length : 0;
onChange && onChange(value);
};
}
componentWillMount() {
const { form, id, initialValue, rules } = this.props;
this.inputed = initialValue ? initialValue.length : 0;
this.fieldDecorator = getFieldDecorator_1.default(form, id, initialValue, rules);
}
render() {
const { placeholder, label, required, form, id, count, last } = this.props;
const omitProps = lodash_omit_1.default(this.props, ['error', 'labelNumber']);
return (react_1.default.createElement(TextareaWrap_1.default, { error: form.getFieldError(id), label: label, required: required, count: count, inputed: this.inputed || (form.getFieldValue(id) && form.getFieldValue(id).length) || 0, last: last }, this.fieldDecorator(react_1.default.createElement(antd_mobile_rn_1.TextareaItem, Object.assign({}, omitProps, { last: true, clear // 注意:antd没有实现label、没有实现安卓的clear
: true, autoHeight: true, style: { marginHorizontal: 15, paddingHorizontal: 0 }, count: count, placeholder: placeholder, onChange: this._onChange })))));
}
}
exports.default = Textarea;
Textarea.defaultProps = {
required: false,
placeholder: '请输入',
count: 0,
last: false,
};
//# sourceMappingURL=Textarea.js.map