mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-07-11 19:40:07 +00:00
42 lines
911 B
JavaScript
42 lines
911 B
JavaScript
/* eslint no-return-assign: 0 */
|
|
import React, { Component } from 'react';
|
|
import cs from 'classnames';
|
|
import PropTypes from 'prop-types';
|
|
|
|
class TextEditor extends Component {
|
|
componentDidMount() {
|
|
const { defaultValue } = this.props;
|
|
this.text.value = defaultValue;
|
|
this.text.focus();
|
|
}
|
|
|
|
render() {
|
|
const { defaultValue, className, ...rest } = this.props;
|
|
const editorClass = cs('form-control editor edit-text', className);
|
|
return (
|
|
<input
|
|
ref={ node => this.text = node }
|
|
type="text"
|
|
className={ editorClass }
|
|
{ ...rest }
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
TextEditor.propTypes = {
|
|
className: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.object
|
|
]),
|
|
defaultValue: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.number
|
|
])
|
|
};
|
|
TextEditor.defaultProps = {
|
|
className: null,
|
|
defaultValue: ''
|
|
};
|
|
export default TextEditor;
|