import React, {Component, PropTypes} from 'react' import Modal from './Modal' import ModalBody from './ModalBody' import ModalHeader from './ModalHeader' import ModalFooter from './ModalFooter' class PromptModal extends Component { _onSubmit (e) { e.preventDefault(); this.props.onSubmit(this.refs.input.value); this.refs.modal.close(); } _setDefaultValueFromProps () { if (this.props.defaultValue) { this.refs.input.value = this.props.defaultValue; } this.refs.input.focus(); if (this.props.selectText) { this.refs.input.select(); } } componentDidMount () { this._setDefaultValueFromProps(); } componentDidUpdate () { this._setDefaultValueFromProps(); } render () { const {onClose, submitName, headerName, ...extraProps} = this.props; return ( {headerName}
) } } PromptModal.propTypes = { onSubmit: PropTypes.func.isRequired, headerName: PropTypes.string.isRequired, defaultValue: PropTypes.string, submitName: PropTypes.string, selectText: PropTypes.bool, onClose: PropTypes.func }; export default PromptModal;