import Ember from 'ember'

# renamed from number-input to number-input-with-panda in favour of the ember-cli-dunlop version
# using number-input numericValue=path.to.value
export default Ember.Component.extend
  classNames: ['number-input']
  step: 1
  stringValue: ''
  value: null
  didReceiveAttrs: ->
    value = @get('value')
    if value or value is 0 or value is '0'
      @set 'stringValue', value.toString()
    else
      @set 'stringValue', ''
  actions:
    set_value: (value) ->
      @set 'stringValue', value
      if value or value is 0 or value is '0'
        @set 'value', parseInt(value, 10)
      else
        @set 'value', null
      false
