material 0.9.9 → 0.9.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/button.js CHANGED
@@ -57,6 +57,8 @@ class Button extends Control {
57
57
  if (data) dataset(this.element, data)
58
58
  if (caseOption) this.element.classList.add(`${caseOption}-case`)
59
59
  if (this.options.ripple) ripple(this.element)
60
+
61
+ if (this.options.disabled) this.disable()
60
62
  }
61
63
 
62
64
  styleAttributes () {
@@ -0,0 +1,45 @@
1
+ import Component from './component'
2
+ import events from '../module/events'
3
+ import build from '../form/build'
4
+
5
+ class Form {
6
+ static base = 'form'
7
+
8
+ constructor (options) {
9
+ this.options = { ...this.constructor.defaults, ...options }
10
+
11
+ const mixins = this.options.mixins || []
12
+
13
+ for (let i = 0; i < mixins.length; i++) {
14
+ Object.assign(this, mixins[i])
15
+ }
16
+
17
+ Object.assign(this, build)
18
+
19
+ this.build(this)
20
+
21
+ this.events = {}
22
+
23
+ if (this.options.events) {
24
+ events.attach(this.options.events, this)
25
+ }
26
+ }
27
+
28
+ on (event, listener) {
29
+ if (!this.events[event]) {
30
+ this.events[event] = []
31
+ }
32
+ this.events[event].push(listener)
33
+
34
+ return this
35
+ }
36
+
37
+ emit (event, ...args) {
38
+ if (this.events[event]) {
39
+ this.events[event].forEach(listener => listener.apply(this, args))
40
+ }
41
+ return this
42
+ }
43
+ }
44
+
45
+ export default Form
@@ -0,0 +1,33 @@
1
+ import Component from './component'
2
+ import events from '../module/events'
3
+
4
+ class View extends Component {
5
+ static base = 'view'
6
+
7
+ constructor (options) {
8
+ super(options)
9
+ this.events = {}
10
+
11
+ if (this.options.events) {
12
+ events.attach(this.options.events, this)
13
+ }
14
+ }
15
+
16
+ on (event, listener) {
17
+ if (!this.events[event]) {
18
+ this.events[event] = []
19
+ }
20
+ this.events[event].push(listener)
21
+
22
+ return this
23
+ }
24
+
25
+ emit (event, ...args) {
26
+ if (this.events[event]) {
27
+ this.events[event].forEach(listener => listener.apply(this, args))
28
+ }
29
+ return this
30
+ }
31
+ }
32
+
33
+ export default View
package/src/list/add.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  export default {
3
- add (info, context) {
3
+ add (info, context, silent) {
4
4
  // console.log('list add', info)
5
5
 
6
6
  if (this.options.reverse) {
@@ -44,7 +44,7 @@ export default {
44
44
  this.virtual.update(this.data)
45
45
  }
46
46
 
47
- this.emit('added', info, context)
47
+ if (silent !== true) this.emit('added', info, context)
48
48
 
49
49
  // this.ui.body.scrollTo(0, this.ui.body.scrollTop + 1)
50
50
  // this.ui.body.scrollTo(0, this.ui.body.scrollTop - 1)
package/src/menu.js CHANGED
@@ -87,8 +87,8 @@ class Menu extends Control {
87
87
  offsetY: 8
88
88
  }).show()
89
89
 
90
- this.menu.on('select', (name) => {
91
- this.emit('select', `${obj.name}:${name}`)
90
+ this.menu.on('select', (value, name) => {
91
+ this.emit('select', `${obj.name}:${value}`, name)
92
92
  }).on('destroy', () => {
93
93
  this.menu = null
94
94
  })
@@ -103,9 +103,10 @@ class Menu extends Control {
103
103
 
104
104
  onClick (ev) {
105
105
  if (ev.target.classList.contains('sub')) return
106
- const name = ev.target.getAttribute('name')
107
- if (name) {
108
- this.emit('select', name)
106
+ const value = ev.target.getAttribute('name')
107
+ const name = ev.target.innerHTML
108
+ if (value) {
109
+ this.emit('select', value, name)
109
110
  }
110
111
  }
111
112
 
package/src/text.js CHANGED
@@ -19,7 +19,7 @@ class Text extends Component {
19
19
 
20
20
  set (text) {
21
21
  // console.log('set', text)
22
- if (text === undefined) return
22
+ if (text === 'undefined') text = ''
23
23
 
24
24
  const label = this.options.label || ''
25
25
 
@@ -35,6 +35,7 @@ class Text extends Component {
35
35
  }
36
36
 
37
37
  setText (text) {
38
+ if (text === 'undefined') text = ''
38
39
  this.element.innerHTML = text
39
40
  }
40
41