2017-09-20 03:16:51 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
|
|
|
|
module.exports = ReadOnlyInput
|
|
|
|
|
|
|
|
inherits(ReadOnlyInput, Component)
|
|
|
|
function ReadOnlyInput () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
ReadOnlyInput.prototype.render = function () {
|
|
|
|
const {
|
2017-09-22 22:01:32 +02:00
|
|
|
wrapperClass = '',
|
|
|
|
inputClass = '',
|
2017-09-20 03:16:51 +02:00
|
|
|
value,
|
2017-09-20 14:32:18 +02:00
|
|
|
textarea,
|
2017-09-20 03:16:51 +02:00
|
|
|
} = this.props
|
|
|
|
|
2017-09-20 14:32:18 +02:00
|
|
|
const inputType = textarea ? 'textarea' : 'input'
|
|
|
|
|
2017-09-20 03:16:51 +02:00
|
|
|
return h('div', {className: wrapperClass}, [
|
2017-09-20 14:32:18 +02:00
|
|
|
h(inputType, {
|
2017-09-20 03:16:51 +02:00
|
|
|
className: inputClass,
|
|
|
|
value,
|
|
|
|
readOnly: true,
|
2017-09-20 14:32:18 +02:00
|
|
|
onFocus: event => event.target.select(),
|
2017-09-20 03:16:51 +02:00
|
|
|
}),
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|