import { TextareaItem } from 'antd-mobile';
import styles from './index.less';

export default function TextareaItemMultiRows({config, value, onChange}) {
  const { name, readOnly, rows, required, ...rest } = config;
  let { placeholder } = config;
  if (readOnly) {
    placeholder = '';
  } else {
    placeholder = placeholder || '点击输入';
  }
  return (
    <div className={styles.container}>
      <div className={styles.label}>
        <span style={{ color: required ? 'red' : 'inherit' }}>*&nbsp;</span>
        {name}
      </div>
      <TextareaItem
        rows={rows}
        placeholder={placeholder}
        editable={!readOnly}
        value={value}
        onChange={onChange}
        {...rest}
      />
    </div>
  );
}
