@handie/squirtle
Version:
Widgets for Handie-React
24 lines (23 loc) • 1.18 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { isNumber, getControl } from 'handie-react';
import { TextFieldStructuralWidget } from 'handie-react/dist/widgets/class';
import { getStringInputtableControlProps } from '../../../../utils';
import defaultBehaviors from './behavior';
export default class TextareaEditTextFieldWidget extends TextFieldStructuralWidget {
render() {
let showWordLimit = this.config.showWordLimit;
if (showWordLimit === undefined) {
showWordLimit = this.getBehavior('showWordLimit');
}
const props = Object.assign(Object.assign({}, getStringInputtableControlProps(this)), { rows: this.config.rows || this.getBehavior('rows'), resize: 'none' });
if (this.showValidationRulesAsNative && isNumber(this.props.field.max)) {
props.showWordage = showWordLimit;
}
const TextArea = getControl('TextArea');
return TextArea ? _jsx(TextArea, Object.assign({}, props, { onInput: value => this.onChange(value) }), void 0) : null;
}
componentWillMount() {
super.componentWillMount();
this.setBehaviors('field.textarea', defaultBehaviors);
}
}