aboutsummaryrefslogblamecommitdiffstats
path: root/ui/app/components/readonly-input.js
blob: fcf05fb9ed11c75d12d3c769e84c99d303237209 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                              

                      
          
             
            

                

                                                   
                                              
                  


                            
                                              
              



       
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 {
    wrapperClass = '',
    inputClass = '',
    value,
    textarea,
    onClick,
  } = this.props

  const inputType = textarea ? 'textarea' : 'input'

  return h('div', {className: wrapperClass}, [
    h(inputType, {
      className: inputClass,
      value,
      readOnly: true,
      onFocus: event => event.target.select(),
      onClick,
    }),
  ])
}