'use strict'

// dependencies
var Element = require('vigour-element')
var Observable = require('vigour-js/lib/observable')

// styles
require('vigour-scratch')
require('./style.less')

// components
var Icon = require('../../component/icon')

// properties
Element.prototype.inject(
  require('vigour-element/lib/property/text'),
  require('vigour-element/lib/property/css'),
  require('vigour-element/lib/property/attributes'),
  require('../../property')
)

/**
 * Select element
 * @memberOf UIKit
 */
module.exports = new Element({
  node: 'label',

  // css defaults
  ui: {
    name: 'select',
    scheme: 'graylight',
    size: 'medium',
    state: 'clean',
    atomic: 'atom',
    childOf: 'form-element',
    interactive: false
  },

  // properties: {
  //   placeholder: new Observable({
  //     on: {
  //       data () {
  //         if (this.parent) {
  //           if (this.parent.options.placeholder) {
  //             this.parent.options.placeholder.text.val = this.val
  //           }
  //         }
  //       }
  //     }
  //   })
  // },

  options: {
    node: 'select',

    ChildConstructor: new Element({
      node: 'option'
    }),

    placeholder: {
      attributes: {
        disabled: 'disabled',
        selected: 'selected',
        value: ''
      },
      text: 'Select your option'
    },

    on: {
      change: {
        dirty () {
          this.parent.setKey('css', {
            addClass: 'ui-dirty'
          })
        }
      }
    }
  },

  down: new Icon('bottom ui-additional')
}).Constructor

@@ -737,19 +737,16 @@
 %0A  %7D,%0A%0A 
- //
  propert
@@ -754,21 +754,18 @@
 es: %7B%0A  
-//
   
- 
 placehol
@@ -787,19 +787,16 @@
 able(%7B%0A 
- //
      on:
@@ -795,27 +795,24 @@
      on: %7B%0A 
- //
        data 
@@ -813,27 +813,24 @@
  data () %7B%0A 
- //
          if 
@@ -842,27 +842,24 @@
 .parent) %7B%0A 
- //
            i
@@ -898,18 +898,16 @@
 er) %7B%0A  
-//
         
@@ -902,33 +902,32 @@
 %7B%0A              
- 
 this.parent.opti
@@ -963,19 +963,16 @@
 is.val%0A 
- //
         
@@ -982,18 +982,16 @@
 %7D%0A  
-//
         
  %7D%0A 
@@ -982,31 +982,27 @@
 %7D%0A          
- 
 %7D%0A 
- //
        %7D%0A  /
@@ -999,19 +999,16 @@
      %7D%0A 
- //
      %7D%0A 
@@ -1012,20 +1012,14 @@
 %7D%0A  
-//
   
- 
 %7D)%0A 
- //
  %7D,%0A

bring select back