material 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +1 -5
  2. package/dist/demo-bundle.js +2281 -2
  3. package/dist/demo-bundle.js.map +7 -1
  4. package/dist/demo.js +13 -13
  5. package/esbuild.js +22 -0
  6. package/esbuild.watch.js +25 -0
  7. package/form.js +27 -0
  8. package/index.js +59 -58
  9. package/list.js +35 -0
  10. package/package.json +8 -17
  11. package/src/appbar.js +7 -204
  12. package/src/badge.js +27 -0
  13. package/src/button.js +127 -177
  14. package/src/calendar.js +53 -55
  15. package/src/card.js +1 -3
  16. package/src/checkbox.js +5 -55
  17. package/src/component.js +0 -2
  18. package/src/container.js +0 -2
  19. package/src/datehour.js +38 -0
  20. package/src/dialog.js +104 -151
  21. package/src/divider.js +1 -3
  22. package/src/drawer.js +1 -19
  23. package/src/element/attribute.js +7 -10
  24. package/src/element/build.js +6 -7
  25. package/src/element/create.js +3 -6
  26. package/src/element/event.js +2 -2
  27. package/src/element/insert.js +6 -17
  28. package/src/element/observer.js +22 -0
  29. package/src/element/offset.js +2 -2
  30. package/src/element/style.js +12 -12
  31. package/src/element.js +2 -2
  32. package/src/field/email.js +9 -44
  33. package/src/field/image.js +17 -51
  34. package/src/{control/file.js → file.js} +15 -45
  35. package/src/form/build.js +7 -7
  36. package/src/form/controller.js +8 -8
  37. package/src/form/create.js +1 -1
  38. package/src/form/data.js +9 -9
  39. package/src/form/delete.js +1 -1
  40. package/src/form/render.js +9 -9
  41. package/src/form/set.js +1 -1
  42. package/src/form/submit.js +6 -6
  43. package/src/form/update.js +3 -3
  44. package/src/form/verify.js +6 -6
  45. package/src/form.js +9 -11
  46. package/src/icon.js +4 -6
  47. package/src/image.js +39 -106
  48. package/src/item.js +1 -3
  49. package/src/layout.js +14 -14
  50. package/src/{control/link.js → link.js} +13 -32
  51. package/src/list/build.js +10 -10
  52. package/src/list/click.js +3 -3
  53. package/src/list/collection.js +1 -1
  54. package/src/list/filter.js +11 -11
  55. package/src/list/image.js +3 -3
  56. package/src/list/render.js +15 -15
  57. package/src/list/request.js +8 -8
  58. package/src/list/search.js +12 -12
  59. package/src/list/select.js +18 -18
  60. package/src/list/status.js +1 -1
  61. package/src/list/update.js +6 -6
  62. package/src/list/virtual.js +20 -20
  63. package/src/list/virtual.new.js +5 -5
  64. package/src/list.js +29 -217
  65. package/src/loading.js +73 -0
  66. package/src/map/build.js +2 -2
  67. package/src/map/countries.js +8 -8
  68. package/src/map/display.js +13 -13
  69. package/src/map/focus.js +7 -7
  70. package/src/map/select.js +2 -2
  71. package/src/map/set.js +3 -3
  72. package/src/map/viewport.js +11 -11
  73. package/src/menu.js +59 -115
  74. package/src/mixin/control.js +3 -3
  75. package/src/mixin/controller.js +5 -5
  76. package/src/mixin/create.js +1 -1
  77. package/src/mixin/display.js +1 -2
  78. package/src/mixin/events.js +4 -16
  79. package/src/mixin/focus.js +1 -1
  80. package/src/mixin/icon.js +2 -2
  81. package/src/mixin/init.js +2 -2
  82. package/src/mixin/insert.js +7 -29
  83. package/src/mixin/label.js +2 -2
  84. package/src/mixin/settings.js +5 -5
  85. package/src/module/attach.js +35 -49
  86. package/src/{control/module → module}/attributes.js +4 -4
  87. package/src/module/build.js +12 -12
  88. package/src/module/classify.js +4 -4
  89. package/src/module/controller.js +5 -32
  90. package/src/module/css.js +12 -84
  91. package/src/module/dataset.js +1 -1
  92. package/src/module/dom.js +8 -3
  93. package/src/module/dot.js +4 -4
  94. package/src/module/emitter.js +1 -1
  95. package/src/module/event.js +2 -2
  96. package/src/module/events.js +29 -35
  97. package/src/module/extract.js +10 -10
  98. package/src/module/last.js +18 -0
  99. package/src/module/mediator.js +1 -13
  100. package/src/module/object.js +4 -4
  101. package/src/module/observer.js +43 -16
  102. package/src/module/remove.js +10 -10
  103. package/src/module/ripple.js +19 -24
  104. package/src/module/scrollbar.js +10 -14
  105. package/src/module/smoothscroll.js +5 -9
  106. package/src/module/utils.js +14 -23
  107. package/src/module/viewport.js +5 -5
  108. package/src/navigation.js +19 -0
  109. package/src/progress.js +1 -11
  110. package/src/search.js +66 -0
  111. package/src/select.js +58 -273
  112. package/src/{control/selecter.js → selecter.js} +42 -42
  113. package/src/selector.js +3 -3
  114. package/src/skin/material/component/navigation.sass +9 -0
  115. package/src/skin/material/control/button.sass +10 -0
  116. package/src/slider.js +1 -3
  117. package/src/snackbar.js +72 -50
  118. package/src/switch.js +111 -103
  119. package/src/{control/switcher.js → switcher.js} +28 -31
  120. package/src/tabs.js +4 -5
  121. package/src/tabview.js +26 -46
  122. package/src/text.js +25 -74
  123. package/src/textfield.js +97 -234
  124. package/src/toolbar.js +12 -12
  125. package/src/tooltip.js +7 -7
  126. package/src/tree.js +10 -66
  127. package/src/view/build.js +2 -2
  128. package/src/view/dataset.js +1 -1
  129. package/src/view.js +9 -74
  130. package/rollup.config.js +0 -34
  131. package/src/banner.js +0 -231
  132. package/src/control/button.js +0 -239
  133. package/src/control/button.new.js +0 -190
  134. package/src/control/datehour.js +0 -65
  135. package/src/control/dialog.js +0 -175
  136. package/src/control/image.js +0 -92
  137. package/src/control/list.js +0 -67
  138. package/src/control/loading.js +0 -128
  139. package/src/control/menu.js +0 -85
  140. package/src/control/module/addclass.js +0 -16
  141. package/src/control/search.js +0 -98
  142. package/src/control/select.js +0 -130
  143. package/src/control/snackbar.js +0 -91
  144. package/src/control/switch.js +0 -272
  145. package/src/control/text.js +0 -70
  146. package/src/control/textfield.js +0 -177
  147. package/src/element/ripple.js +0 -90
  148. package/src/tabs/setup.js +0 -0
package/src/tabview.js CHANGED
@@ -1,38 +1,24 @@
1
- import emitter from './module/emitter'
2
- import observer from './module/observer'
1
+ import EventEmitter from './mixin/emitter'
2
+ import observer from './element/observer'
3
+ import build from './module/build'
3
4
  import display from './view/display'
4
5
 
5
- /**
6
- * Class Tab
7
- * @class
8
- * @since 0.0.1
9
- * @example
10
- * var tab = new TabView()
11
- */
12
-
13
- var defaults = {
14
- class: 'tabview',
15
- mode: 'style' // css
16
- }
6
+ class TabView extends EventEmitter {
7
+ static defaults = {
8
+ base: 'view',
9
+ class: 'tabview',
10
+ mode: 'style'
11
+ }
17
12
 
18
- class TabView {
19
- /**
20
- * The init method of the Button class
21
- * @param {Object} The element attributes
22
- * @private
23
- * @return {DOMElement} The dom element
24
- */
25
13
  constructor (options) {
26
- // console.log('TabView')
27
- this.options = Object.assign({}, defaults, options || {})
28
- Object.assign(this, emitter, display)
14
+ super()
29
15
 
16
+ this.init(options)
30
17
  this.build()
31
18
 
32
- var ready = false
19
+ let ready = false
33
20
 
34
21
  observer.insert(this.element, () => {
35
- // console.log('!!! inserted')
36
22
  if (!ready) {
37
23
  ready = true
38
24
  this.setup()
@@ -45,15 +31,9 @@ class TabView {
45
31
  return this
46
32
  }
47
33
 
48
- build () {
49
- this.element = document.createElement(this.options.tag || 'div')
50
- this.element.classList.add('tabview')
51
-
52
- this.element.classList.add('view')
53
-
54
- if (this.options.class !== 'tabview') {
55
- this.element.classList.add(this.options.class)
56
- }
34
+ init (options) {
35
+ this.options = { ...TabView.defaults, ...options }
36
+ Object.assign(this, build, display)
57
37
 
58
38
  this.ui = {}
59
39
  }
@@ -72,7 +52,7 @@ class TabView {
72
52
 
73
53
  // console.log('views', this.ui.views)
74
54
 
75
- for (var i = 0; i < this.ui.views.length; i++) {
55
+ for (let i = 0; i < this.ui.views.length; i++) {
76
56
  if (this.ui.views[i].dataset) {
77
57
  this.views.push(this.ui.views[i].dataset.view)
78
58
  this.view[this.ui.views[i].dataset.view] = this.ui.views[i]
@@ -98,7 +78,7 @@ class TabView {
98
78
  select (view) {
99
79
  // console.log('select', view, this.ui.tabs)
100
80
  if (this.ui && this.ui.tabs) {
101
- var button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
81
+ const button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
102
82
  // console.log('tab', button)
103
83
  if (button) {
104
84
  this.click(button)
@@ -111,7 +91,7 @@ class TabView {
111
91
  disable (view) {
112
92
  // console.log('select', view)
113
93
  if (this.ui && this.ui.tabs) {
114
- var button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
94
+ const button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
115
95
  // console.log('tab', button)
116
96
  if (button) {
117
97
  button.disabled = 'disabled'
@@ -125,7 +105,7 @@ class TabView {
125
105
  // console.log('select', view)
126
106
 
127
107
  if (this.ui && this.ui.tabs) {
128
- var button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
108
+ const button = this.ui.tabs.querySelector('[data-view="' + view + '"]')
129
109
  // console.log('tab', button)
130
110
  if (button) {
131
111
  button.disabled = false
@@ -137,7 +117,7 @@ class TabView {
137
117
 
138
118
  hideView () {
139
119
  // console.log('hideView')
140
- for (var i = 0; i < this.ui.views.length; i++) {
120
+ for (let i = 0; i < this.ui.views.length; i++) {
141
121
  // console.log('hide', this.ui.views[i])
142
122
  this.ui.views[i].classList.add('hide')
143
123
  }
@@ -145,7 +125,7 @@ class TabView {
145
125
 
146
126
  click (button) {
147
127
  // console.log('click', button.dataset.view, true)
148
- var view = this.ui.view.querySelector('[data-view="' + button.dataset.view + '"]')
128
+ const view = this.ui.view.querySelector('[data-view="' + button.dataset.view + '"]')
149
129
  this.hideView()
150
130
 
151
131
  if (this.button) {
@@ -172,14 +152,14 @@ class TabView {
172
152
  indicator (button) {
173
153
  if (!this.ui.indicator) return
174
154
 
175
- var t = this.ui.tabs.getBoundingClientRect()
176
- var b = button.getBoundingClientRect()
155
+ const tabs = this.ui.tabs.getBoundingClientRect()
156
+ var button = button.getBoundingClientRect()
177
157
 
178
158
  // console.log('tab rect', b.height, b.height)
179
159
 
180
- this.ui.indicator.style.top = t.height - 2 + 'px'
181
- this.ui.indicator.style.left = (b.left - t.left) + 'px'
182
- this.ui.indicator.style.width = b.width + 'px'
160
+ this.ui.indicator.style.top = tabs.height - 2 + 'px'
161
+ this.ui.indicator.style.left = (button.left - tabs.left) + 'px'
162
+ this.ui.indicator.style.width = button.width + 'px'
183
163
  }
184
164
  }
185
165
 
package/src/text.js CHANGED
@@ -1,96 +1,47 @@
1
- 'use strict'
1
+ import build from './module/build'
2
2
 
3
- import create from './mixin/create'
4
- import insert from './mixin/insert'
5
-
6
- var defaults = {
7
- prefix: 'material',
8
- class: 'text',
9
- type: 'default',
10
- types: {
11
- default: 'span',
12
- display4: 'h1',
13
- display3: 'h1',
14
- display2: 'h1',
15
- display1: 'h1',
16
- headline: 'h1',
17
- title: 'h2',
18
- subheading2: 'h3',
19
- subheading1: 'h4',
20
- body: 'p',
21
- body2: 'aside',
22
- caption: 'span'
3
+ class Text {
4
+ static defaults = {
5
+ class: 'text',
6
+ tag: 'span'
23
7
  }
24
- }
25
8
 
26
- /**
27
- * this class creates a text component
28
- *
29
- * @since 0.0.6
30
- * @category Element
31
- * @param {HTMLElement} element Related element
32
- * @param {String} className the className to add
33
- * grouped values.
34
- * @returns {HTMLElement} The modified element
35
- * @example
36
- *
37
- * var text = new Text({
38
- * text: 'hello',
39
- * type: 'title'
40
- * }).insert(document.body);
41
- *
42
- * // => Hello
43
- */
44
- class Text {
45
- /**
46
- * init
47
- * @return {Object} The class options
48
- */
49
9
  constructor (options) {
50
10
  this.init(options)
51
11
  this.build()
52
-
53
- return this
12
+ this.setup()
54
13
  }
55
14
 
56
15
  init (options) {
57
- this.options = Object.assign({}, defaults, options || {})
58
-
59
- Object.assign(this, insert)
16
+ this.options = Object.assign({}, Text.defaults, options || {})
17
+ Object.assign(this, build)
60
18
  }
61
19
 
62
- /**
63
- * Build function for item
64
- * @return {Object} This class instance
65
- */
66
- build () {
67
- this.options.tag = this.options.types[this.options.type]
68
-
69
- this.element = create(this.options)
70
-
20
+ setup () {
71
21
  if (this.options.text) {
72
22
  this.set(this.options.text)
73
23
  }
74
-
75
- if (this.options.container) {
76
- this.insert(this.options.container)
77
- }
78
- return this
79
24
  }
80
25
 
81
- /**
82
- * Get or set text value of the element
83
- * @param {string} value The text to set
84
- * @returns {*}
85
- */
86
- set (value) {
87
- if (value) {
88
- this.element.textContent = value
26
+ set (text) {
27
+ // console.log('set', text)
28
+ if (text === undefined) return
29
+
30
+ const label = this.options.label || ''
31
+
32
+ if (this.options.textFirst) {
33
+ this.element.innerHTML = text + label
89
34
  } else {
90
- this.element.textContent = ''
35
+ this.element.innerHTML = label + text
91
36
  }
92
37
 
93
- return this
38
+ if (this.options.spaceAfter) {
39
+ this.element.innerHTML = this.element.innerHTML + ' '
40
+ }
41
+ }
42
+
43
+ setText (text) {
44
+ this.element.innerHTML = text
94
45
  }
95
46
  }
96
47
 
package/src/textfield.js CHANGED
@@ -1,307 +1,170 @@
1
- 'use strict'
2
-
3
1
  import emitter from './module/emitter'
4
2
  import attach from './module/attach'
3
+ import dataset from './module/dataset'
4
+ import attributes from './module/attributes'
5
5
 
6
- var defaults = {
7
- prefix: 'material',
8
- class: 'textfield',
9
- type: 'control',
10
- tag: 'div',
11
- events: [
12
- // 'change': '_onChange',
13
- ['input.focus', 'focus'],
14
- ['input.blur', 'blur'],
15
- // ['input.keypress', '_handleInputKeyPress',
16
- ['input.keyup', '_handleInputKeyPress']
17
- // ['input.change', '_onChange']
18
- // 'input.keydown': '_handleInputKeyPress'
19
-
20
- ]
21
- }
22
-
23
- /**
24
- * Textfield class
25
- * @class
26
- */
27
6
  class Textfield {
28
- /**
29
- * Constructor
30
- * @param {Object} options - Component options
31
- * @return {Object} Class instance
32
- */
33
- constructor (options) {
34
- this.options = Object.assign({}, defaults, options || {})
7
+ static isComponent () {
8
+ return true
9
+ }
35
10
 
36
- this.init()
11
+ static defaults = {
12
+ class: 'textfield',
13
+ attributes: ['type', 'name', 'title', 'maxlength', 'pattern', 'min', 'max', 'placeholder', 'readonly', 'autocomplete', 'required', 'disabled'],
14
+ events: [
15
+ ['input.input', 'onInput'],
16
+ ['input.focus', 'onFocus'],
17
+ ['input.blur', 'onBlur'],
18
+ ['input.click', 'onClick']
19
+ ]
20
+ }
21
+
22
+ constructor (options) {
23
+ this.init(options)
37
24
  this.build()
38
25
  this.attach()
39
-
40
- return this
41
26
  }
42
27
 
43
- /**
44
- * init
45
- * @param {Object} options The class options
46
- * @return {Object} The class instance
47
- */
48
- init () {
49
- Object.assign(this, emitter, attach)
50
-
51
- this.value = this.options.value
52
- this.readonly = this.options.readonly
53
- this.disabled = this.options.disabled
54
-
55
- return this
28
+ init (options) {
29
+ this.options = Object.assign({}, Textfield.defaults, options || {})
30
+ Object.assign(this, emitter, attach, dataset)
31
+ // console.log('options', options)
56
32
  }
57
33
 
58
- /**
59
- * [build description]
60
- * @return {Object} The class instance
61
- */
62
34
  build () {
63
- // create a new div as input element
64
- var tag = this.options.tag || 'div'
35
+ const tag = this.options.tag || 'div'
36
+
65
37
  this.element = document.createElement(tag)
66
- this.element.classList.add(this.options.prefix + '-' + this.options.class)
38
+ this.element.classList.add('textfield')
39
+
40
+ if (this.options.class !== 'textfield') {
41
+ this.element.classList.add(this.options.class)
42
+ }
67
43
 
68
44
  this.buildLabel()
69
45
  this.buildInput()
70
- this.buildUnderline()
71
46
 
72
- if (this.disabled) {
73
- css.add(this.element, 'is-disabled')
47
+ if (this.options.value) {
48
+ this.set(this.options.value)
74
49
  }
75
50
 
76
- // insert if container this.options is given
77
- if (this.options.container) {
78
- // console.log(this.name, opts.container);
79
- insert(this.element, this.options.container)
51
+ if (this.options.data) {
52
+ dataset(this.element, this.options.data)
80
53
  }
54
+
55
+ if (this.container) {
56
+ this.container.appendChild(this.element)
57
+ }
58
+
59
+ return this
81
60
  }
82
61
 
83
62
  buildLabel () {
84
- this.label = document.createElement('label')
85
- this.label.classList.add(this.options.class + '-label')
86
- this.element.appendChild(this.label)
87
-
88
- if (this.options.label !== false) {
89
- this.setLabel()
63
+ if (this.options.label) {
64
+ this.label = document.createElement('label')
65
+ this.label.classList.add('label')
66
+ this.label.innerHTML = this.options.label
67
+ this.element.appendChild(this.label)
90
68
  }
91
69
  }
92
70
 
93
- /**
94
- * [_initInput description]
95
- * @return {Object} The class instance
96
- */
97
71
  buildInput () {
98
- this.input = document.createElement('input')
99
- this.input.classList.add(this.options.class + '-input')
100
- this.input.setAttribute('type', 'text')
101
- this.element.appendChild(this.input)
102
-
103
- if (this.options.name) {
104
- this.input.setAttribute('name', this.options.name)
72
+ let tag = 'input'
73
+ if (this.options.type === 'multiline') {
74
+ tag = 'textarea'
105
75
  }
106
76
 
107
- if (!this.options.value) {
108
- this.element.classList.add('is-empty')
109
- }
110
-
111
- if (this.readonly) {
112
- this.input.setAttribute('readonly', 'readonly')
113
- this.input.setAttribute('tabindex', '-1')
114
- }
77
+ this.input = document.createElement(tag)
78
+ this.input.classList.add('input')
115
79
 
116
- return this.input
117
- }
80
+ this.element.appendChild(this.input)
118
81
 
119
- /**
120
- * _initUnderline
121
- * @return {Object} The class instance
122
- */
123
- buildUnderline () {
124
- this.underline = document.createElement('span')
125
- this.underline.classList.add(this.options.class + '-underline')
126
- this.element.appendChild(this.underline)
127
- }
82
+ attributes(this.input, this.options)
128
83
 
129
- /**
130
- * Setter
131
- * @param {string} prop
132
- * @param {string} value
133
- */
134
- set (prop, value, options) {
135
- switch (prop) {
136
- case 'value':
137
- this.setValue(value, options)
138
- break
139
- case 'label':
140
- this.setLabel(value, options)
141
- break
142
- case 'disabled':
143
- if (value === true) {
144
- this.disable()
145
- } else if (value === false) {
146
- this.enable()
147
- }
148
- break
149
- default:
150
- this.setValue(prop, value)
84
+ if (this.options.focus) {
85
+ this.input.focus()
151
86
  }
152
-
153
- return this
154
87
  }
155
88
 
156
- /**
157
- * [buildLabel description]
158
- * @return {Object} The class instance
159
- */
160
- setLabel (label) {
161
- label = label || this.options.label
162
- var text
163
-
164
- if (label === null || label === false) {
165
- text = ''
166
- } else if (this.options.label) {
167
- text = label
168
- } else {
169
- text = this.options.name
170
- }
89
+ onInput (ev) {
90
+ // console.log('onInput', this.value, this.input.value)
171
91
 
172
- this.label.textContent = text
92
+ this.emit('change', ev)
173
93
  }
174
94
 
175
- disable () {
176
- this.disabled = true
177
-
178
- this.input.setAttribute('disabled', 'disabled')
179
- this.element.classList.add('is-disabled')
180
- return this
95
+ onFocus (ev) {
96
+ this.element.classList.add('focused')
97
+ this.emit('focus', ev)
181
98
  }
182
99
 
183
- enable () {
184
- this.disabled = false
100
+ onBlur (ev) {
101
+ this.element.classList.remove('focused')
102
+ this.emit('blur', ev)
103
+ }
185
104
 
186
- this.element.input.removeAttribute('disabled')
187
- this.element.classList.remove('is-disabled')
188
- return this
105
+ onClick (ev) {
106
+ // console.log('click')
107
+ this.emit('click', ev)
189
108
  }
190
109
 
191
110
  /**
192
- * Getter
111
+ * Setter
193
112
  * @param {string} prop
194
113
  * @param {string} value
114
+ * @return {Object} The class instance
195
115
  */
196
- get (prop) {
197
- var value
198
-
116
+ set (prop, value) {
117
+ // console.log('set', this.element, prop, value)
199
118
  switch (prop) {
200
119
  case 'value':
201
- value = this.getValue()
120
+ this.setValue(value)
202
121
  break
203
- case 'name':
204
- value = this.name
122
+ case 'label':
123
+ this.setLabel(value)
205
124
  break
206
125
  default:
207
- return this.getValue()
126
+ // console.log('prop', prop)
127
+ this.setValue(prop)
208
128
  }
209
129
 
210
- return value
211
- }
212
-
213
- /**
214
- * [getValue description]
215
- * @return {Object} The class instance
216
- */
217
- getValue () {
218
- // console.log('getValue', this);
219
- return this.input.value
130
+ return this
220
131
  }
221
132
 
222
- /**
223
- * [setValue description]
224
- * @param {string} value [description]
225
- */
226
- setValue (value, silent) {
227
- // console.log('setValue', value, silent);
228
- this.input.value = value
229
-
230
- if (value) {
231
- this.element.classList.remove('is-empty')
133
+ setValue (value) {
134
+ // console.log('set', typeof value, value)
135
+ if (value && value !== 'undefined') {
136
+ this.value = value
137
+ this.input.value = value
232
138
  } else {
233
- this.element.classList.add('is-empty')
139
+ this.input.value = ''
234
140
  }
235
-
236
- if (!silent) { this.emit('change', value) }
237
141
  }
238
142
 
239
- /**
240
- * [_initValue description]
241
- * @return {Object} The class instance
242
- */
243
- _initValue () {
244
- var opts = this.options
245
-
246
- // create a new div as input element
247
- if (opts.value) {
248
- this.setValue(opts.value)
143
+ setLabel (value) {
144
+ // console.log('setLabel', value)
145
+ if (this.label) {
146
+ this.label.innerHTML = value
249
147
  }
250
148
  }
251
149
 
252
- /**
253
- * [_onFocus description]
254
- * @return {Object} The class instance
255
- */
256
- _handleInputKeyPress (e) {
257
- // console.log('_handleInputKeyPress', e);
258
- if (this.readonly) return
150
+ setText (value) {
151
+ this.setLabel(value)
259
152
 
260
- if (this.get('value') === '') {
261
- this.element.classList.add('is-empty')
262
- } else {
263
- this.element.classList.remove('is-empty')
153
+ if (this.options.placeholder) {
154
+ this.input.placeholder = value
264
155
  }
265
-
266
- this.emit('change', this.getValue())
267
156
  }
268
157
 
269
- /**
270
- * focus method
271
- * @return {?} [description]
272
- */
273
- focus () {
274
- if (this.disabled) return this
275
- if (this.readonly) return this
276
-
277
- this.element.classList.add('is-focused')
278
- if (this.input !== document.activeElement) { this.input.focus() }
279
- return this
158
+ hide () {
159
+ this.element.classList.add('hide')
280
160
  }
281
161
 
282
- /**
283
- * blur method
284
- * @return {?} [description]
285
- */
286
- blur () {
287
- if (this.readonly) return this
288
-
289
- this.element.classList.remove('is-focused')
290
-
291
- return this
162
+ show () {
163
+ this.element.classList.remove('hide')
292
164
  }
293
- /**
294
- * [setError description]
295
- * @param {string} error Error description
296
- */
297
- setError (error) {
298
- if (error) {
299
- this.addClass('field-error')
300
- if (this.error) { this.error.set('html', error) }
301
- } else {
302
- if (this.error) { this.removeClass('field-error') }
303
- if (this.error) { this.error.set('html', '') }
304
- }
165
+
166
+ get () {
167
+ return this.input.value
305
168
  }
306
169
  }
307
170