material 0.6.2 → 0.7.1

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 (98) hide show
  1. package/form.js +27 -0
  2. package/index.js +61 -51
  3. package/list.js +35 -0
  4. package/package.json +5 -1
  5. package/src/appbar.js +7 -204
  6. package/src/badge.js +27 -0
  7. package/src/button.js +160 -161
  8. package/src/calendar.js +8 -10
  9. package/src/card.js +4 -6
  10. package/src/checkbox.js +8 -10
  11. package/src/component.js +4 -6
  12. package/src/container.js +4 -6
  13. package/src/datehour.js +38 -0
  14. package/src/dialog.js +106 -153
  15. package/src/divider.js +4 -6
  16. package/src/drawer.js +11 -13
  17. package/src/field/email.js +5 -5
  18. package/src/field/image.js +4 -4
  19. package/src/{control/file.js → file.js} +18 -48
  20. package/src/form/build.js +7 -7
  21. package/src/form/verify.js +2 -2
  22. package/src/form.js +6 -8
  23. package/src/icon.js +8 -10
  24. package/src/image.js +39 -106
  25. package/src/item.js +7 -9
  26. package/src/layout.js +10 -10
  27. package/src/link.js +50 -0
  28. package/src/list/add.js +1 -1
  29. package/src/list/build.js +9 -9
  30. package/src/list/collection.js +1 -1
  31. package/src/list/display.js +10 -10
  32. package/src/list/filter.js +2 -2
  33. package/src/list/request.js +1 -1
  34. package/src/list/search.js +7 -7
  35. package/src/list.js +29 -217
  36. package/src/loading.js +73 -0
  37. package/src/map/build.js +6 -6
  38. package/src/map/display.js +8 -8
  39. package/src/menu.js +60 -116
  40. package/src/{component → mixin}/control.js +10 -10
  41. package/src/{component → mixin}/create.js +1 -1
  42. package/src/{module → mixin}/display.js +9 -22
  43. package/src/{component → mixin}/events.js +2 -2
  44. package/src/{component → mixin}/focus.js +2 -3
  45. package/src/{component → mixin}/insert.js +3 -25
  46. package/src/{control/module → module}/attributes.js +2 -2
  47. package/src/module/build.js +11 -7
  48. package/src/{component → module}/classify.js +0 -13
  49. package/src/module/dom.js +1 -57
  50. package/src/module/events.js +4 -2
  51. package/src/{component → module}/ripple.js +15 -42
  52. package/src/navigation.js +19 -0
  53. package/src/progress.js +7 -9
  54. package/src/search.js +71 -0
  55. package/src/select.js +58 -273
  56. package/src/{control/selecter.js → selecter.js} +20 -20
  57. package/src/selector.js +32 -32
  58. package/src/skin/material/component/navigation.sass +1 -0
  59. package/src/skin/material/control/button.sass +10 -0
  60. package/src/slider.js +32 -34
  61. package/src/snackbar.js +72 -51
  62. package/src/switch.js +115 -107
  63. package/src/{control/switcher.js → switcher.js} +33 -36
  64. package/src/tabs.js +8 -8
  65. package/src/tabview.js +8 -8
  66. package/src/text.js +25 -74
  67. package/src/textfield.js +97 -234
  68. package/src/toolbar.js +28 -28
  69. package/src/tooltip.js +11 -11
  70. package/src/tree.js +12 -16
  71. package/src/view/build.js +6 -6
  72. package/src/view/display.js +16 -16
  73. package/src/view.js +5 -5
  74. package/src/banner.js +0 -231
  75. package/src/component/click.js +0 -17
  76. package/src/control/button.js +0 -267
  77. package/src/control/button.new.js +0 -190
  78. package/src/control/datehour.js +0 -65
  79. package/src/control/dialog.js +0 -175
  80. package/src/control/image.js +0 -92
  81. package/src/control/link.js +0 -69
  82. package/src/control/list.js +0 -67
  83. package/src/control/loading.js +0 -128
  84. package/src/control/menu.js +0 -85
  85. package/src/control/search.js +0 -98
  86. package/src/control/select.js +0 -130
  87. package/src/control/snackbar.js +0 -89
  88. package/src/control/switch.js +0 -272
  89. package/src/control/text.js +0 -70
  90. package/src/control/textfield.js +0 -177
  91. /package/src/{component → mixin}/controller.js +0 -0
  92. /package/src/{component → mixin}/emitter.js +0 -0
  93. /package/src/{component → mixin}/icon.js +0 -0
  94. /package/src/{component → mixin}/init.js +0 -0
  95. /package/src/{component → mixin}/label.js +0 -0
  96. /package/src/{component → mixin}/settings.js +0 -0
  97. /package/src/{control/module → module}/addclass.js +0 -0
  98. /package/src/{tabs/setup.js → module/last.js} +0 -0
package/src/image.js CHANGED
@@ -1,124 +1,57 @@
1
- 'use strict'
1
+ import build from './module/build'
2
2
 
3
- // import insert from './component/insert'
4
- import css from './module/css'
5
- import insert from './element/insert'
6
- import control from './component/control'
7
-
8
- var defaults = {
9
- prefix: 'material',
10
- class: 'image',
11
- tag: 'div'
12
- }
13
-
14
- /**
15
- * The item class is used for example as item list
16
- *
17
- * @class
18
- * @extends {Component}
19
- * @return {Object} The class instance
20
- * @example new Item(object);
21
- */
22
3
  class Image {
23
- /**
24
- * init
25
- * @return {Object} The class options
26
- */
4
+ static defaults = {
5
+ class: 'image',
6
+ tag: 'div',
7
+ format: 'thumb'
8
+ }
9
+
27
10
  constructor (options) {
28
11
  this.init(options)
29
12
  this.build()
30
-
31
- return this
32
13
  }
33
14
 
34
- /**
35
- * [init description]
36
- * @param {?} options [description]
37
- * @return {?} [description]
38
- */
39
15
  init (options) {
40
- this.options = Object.assign({}, defaults, options || {})
41
- Object.assign(this, control)
16
+ this.options = Object.assign({}, Image.defaults, options || {})
17
+ Object.assign(this, build)
42
18
  }
43
19
 
44
- /**
45
- * Build function for item
46
- * @return {Object} This class instance
47
- */
48
- build (options) {
49
- options = options || this.options
50
-
51
- var tag = options.tag || 'div'
52
- var text = options.text || options.label
53
- this.root = document.createElement(tag)
54
-
55
- // if (options.src) {
56
- // this.root.setAttribute('style', 'background-image: url(' + options.src + ')')
57
-
58
- if (options.src) {
59
- this.image = document.createElement('img')
60
- this.image.setAttribute('src', options.src)
61
- css.add(this.image, this.options.class + '-image')
62
- insert(this.image, this.root)
63
- }
64
-
65
- this.info = document.createElement('span')
66
- css.add(this.info, this.options.class + '-info')
67
-
68
- insert(this.info, this.root)
69
-
70
- this.label(text, this.info)
71
-
72
- // this.label = this.element.label
73
-
74
- this.icon(this.options.icon, this.info, 'bottom')
75
-
76
- // if (text) {
77
- // this.label = document.createElement('span')
78
- // this.label.innerText = text
79
- // css.add(this.label, this.options.class + '-label')
80
- // insert(this.label, this.root)
81
- // }
82
-
83
- css.add(this.root, this.options.prefix + '-' + this.options.class)
84
-
85
- if (options.css) { css.add(this.root, options.css) }
86
- // css.add(this.root, this.options.class + '-adjust');
87
-
88
- if (this.options.container) {
89
- this.insert(this.options.container)
90
- }
91
- }
92
-
93
- /**
94
- * [insert description]
95
- * @param {?} container [description]
96
- * @param {?} context [description]
97
- * @return {?} [description]
98
- */
99
- insert (container, context) {
100
- insert(this.root, container, context)
101
-
102
- return this
103
- }
104
-
105
- /**
106
- * Get or set text value of the element
107
- * @param {string} value The text to set
108
- * @returns {*}
109
- */
110
- set (value) {
111
- if (value) {
112
- if (this.root.innerText) {
113
- this.root.innerText = value
20
+ set (src) {
21
+ // console.log('set', src)
22
+ if (!src) {
23
+ this.element.style.backgroundImage = ''
24
+ } else {
25
+ var url = null
26
+
27
+ if (src.format) {
28
+ var format = this.sanitize(src.format)
29
+
30
+ if (format.length > 0) {
31
+ var index = format.indexOf(this.options.format)
32
+ if (index === -1) {
33
+ format = src.format[0] + '/'
34
+ } else {
35
+ format = this.options.format + '/'
36
+ }
37
+ }
38
+
39
+ url = src.url + format
114
40
  } else {
115
- this.root.textContent = value
41
+ url = src.url
116
42
  }
117
43
 
118
- return this
44
+ this.element.style.backgroundImage = 'url(' + url + src.filename + ')'
119
45
  }
46
+ }
120
47
 
121
- return this
48
+ sanitize (formats) {
49
+ var a = []
50
+ for (var i = 0; i < formats.length; i++) {
51
+ var format = formats[i].replace(/\/$/, '')
52
+ a.push(format)
53
+ }
54
+ return a
122
55
  }
123
56
  }
124
57
 
package/src/item.js CHANGED
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
1
  import Layout from './layout'
4
2
 
5
- import create from './component/create'
6
- import insert from './component/insert'
3
+ import create from './mixin/create'
4
+ import insert from './mixin/insert'
7
5
 
8
6
  var defaults = {
9
7
  prefix: 'material',
@@ -70,14 +68,14 @@ class Item {
70
68
 
71
69
  this.options.tag = this.options.tag
72
70
 
73
- this.root = create(this.options)
71
+ this.element = create(this.options)
74
72
 
75
73
  if (this.options.text) {
76
74
  this.set(this.options.text)
77
75
  }
78
76
 
79
77
  if (this.options.layout) {
80
- this.layout = new Layout(this.options.layout, this.root)
78
+ this.layout = new Layout(this.options.layout, this.element)
81
79
  } else {
82
80
  if (this.options.container) {
83
81
  this.insert(this.options.container)
@@ -92,10 +90,10 @@ class Item {
92
90
  */
93
91
  set (value) {
94
92
  if (value) {
95
- if (this.root.innerText) {
96
- this.root.innerText = value
93
+ if (this.element.innerText) {
94
+ this.element.innerText = value
97
95
  } else {
98
- this.root.textContent = value
96
+ this.element.textContent = value
99
97
  }
100
98
 
101
99
  return this
package/src/layout.js CHANGED
@@ -37,10 +37,10 @@ class Layout {
37
37
  }
38
38
 
39
39
  component = new schema[i](options)
40
- var element = component.root || component
40
+ var element = component.element || component
41
41
 
42
42
  if (level === 1) {
43
- structure.root = element
43
+ structure.element = element
44
44
  }
45
45
 
46
46
  if (name) {
@@ -57,7 +57,7 @@ class Layout {
57
57
  if (component.insert) {
58
58
  component.insert(container)
59
59
  } else {
60
- var wrapper = container.root || container
60
+ var wrapper = container.element || container
61
61
 
62
62
  wrapper.appendChild(element)
63
63
 
@@ -98,30 +98,30 @@ class Layout {
98
98
  // console.log('component', component);
99
99
 
100
100
  if (options.flex) {
101
- css.add(component.root, 'flex-' + options.flex)
101
+ css.add(component.element, 'flex-' + options.flex)
102
102
  } else {
103
103
  var size = options.size
104
104
  if (options.size && options.width) {
105
- component.root.width = size + 'px'
105
+ component.element.width = size + 'px'
106
106
  } else if (options.size && options.height) {
107
- component.root.height = size + 'px'
107
+ component.element.height = size + 'px'
108
108
  }
109
109
  }
110
110
 
111
111
  if (options.position) {
112
- component.root.position = options.position
112
+ component.element.position = options.position
113
113
  }
114
114
 
115
115
  if (options.bottom) {
116
- component.root.bottom = options.bottom
116
+ component.element.bottom = options.bottom
117
117
  }
118
118
 
119
119
  if (options.hide) {
120
- component.root.display = 'none'
120
+ component.element.display = 'none'
121
121
  }
122
122
 
123
123
  if (options.theme) {
124
- css.add(component.root, 'theme' + '-' + options.theme)
124
+ css.add(component.element, 'theme' + '-' + options.theme)
125
125
  }
126
126
  }
127
127
 
package/src/link.js ADDED
@@ -0,0 +1,50 @@
1
+ import build from './module/build'
2
+
3
+ class Link {
4
+ static defaults = {
5
+ class: 'link',
6
+ tag: 'a'
7
+ }
8
+
9
+ constructor (options) {
10
+ this.init(options)
11
+ this.build()
12
+ this.setup()
13
+ }
14
+
15
+ init (options) {
16
+ this.options = Object.assign({}, Link.defaults, options || {})
17
+ Object.assign(this, build)
18
+ }
19
+
20
+ setup () {
21
+ if (this.options.link) {
22
+ this.set(this.options.link)
23
+ }
24
+
25
+ if (this.options.target !== 'blank') {
26
+ this.element.target = this.options.target
27
+ }
28
+
29
+ if (this.options.text) {
30
+ this.element.innerHTML = this.options.text
31
+ }
32
+ }
33
+
34
+ set (link) {
35
+ // console.log('set', text)
36
+ if (link === undefined) return
37
+
38
+ if (this.options.target === 'blank') {
39
+ this.element.href = '#'
40
+ this.element.addEventListener('click', () => {
41
+ window.open(link)
42
+ return false
43
+ })
44
+ } else {
45
+ this.element.href = link
46
+ }
47
+ }
48
+ }
49
+
50
+ export default Link
package/src/list/add.js CHANGED
@@ -24,7 +24,7 @@ export default {
24
24
  this.dataStore[info[this.dataId]] = info
25
25
  // console.log('data', this.data.length, this.data)
26
26
 
27
- if (window.getComputedStyle(this.root, null).display === 'none') {
27
+ if (window.getComputedStyle(this.element, null).display === 'none') {
28
28
  this.virtual.items = this.data
29
29
  } else {
30
30
  this.virtual.update(this.data)
package/src/list/build.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import scrollbar from '../module/scrollbar'
2
- import dataset from '../view/dataset'
2
+ import dataset from '../module/dataset'
3
3
 
4
4
  import Layout from '../layout'
5
5
  import Virtual from './virtual'
6
- import Loading from '../control/loading'
6
+ import Loading from '../loading'
7
7
 
8
8
  export default {
9
9
  build (data) {
@@ -11,14 +11,14 @@ export default {
11
11
 
12
12
  this.dataId = this.options.dataId || '_id'
13
13
 
14
- this.root = document.createElement('div')
15
- this.root.classList.add('list')
14
+ this.element = document.createElement('div')
15
+ this.element.classList.add('list')
16
16
 
17
17
  if (this.options.class) {
18
18
  this.addClass(this.options.class)
19
19
  }
20
20
 
21
- this.root.addEventListener('click', (e) => {
21
+ this.element.addEventListener('click', (e) => {
22
22
  e.stopPropagation()
23
23
  })
24
24
 
@@ -27,17 +27,17 @@ export default {
27
27
  }
28
28
 
29
29
  if (this.options.data) {
30
- dataset(this.root, this.options.data)
30
+ dataset(this.element, this.options.data)
31
31
  }
32
32
 
33
- this.layout = new Layout(this.options.layout.main, this.root)
33
+ this.layout = new Layout(this.options.layout.main, this.element)
34
34
  this.ui = this.layout.component
35
35
 
36
36
  // prepare loading
37
37
  // this.ui.loading = new Loading()
38
38
 
39
39
  if (this.options.container) {
40
- this.options.container.appendChild(this.root)
40
+ this.options.container.appendChild(this.element)
41
41
  }
42
42
 
43
43
  var scrollbarOffset = scrollbar()
@@ -56,7 +56,7 @@ export default {
56
56
  var list = c.split(' ')
57
57
 
58
58
  for (var i = 0; i < list.length; i++) {
59
- this.root.classList.add(list[i])
59
+ this.element.classList.add(list[i])
60
60
  }
61
61
  },
62
62
 
@@ -150,7 +150,7 @@ class Collection {
150
150
  route = this.addParams(route, this.params())
151
151
  }
152
152
 
153
- if (this.ui.filter && this.ui.filter.root.classList.contains('selected')) {
153
+ if (this.ui.filter && this.ui.filter.element.classList.contains('selected')) {
154
154
  route = this.addParams(route, this.getFilter())
155
155
  }
156
156
 
@@ -10,9 +10,9 @@ export default {
10
10
  show () {
11
11
  // console.log('show', this.visible)
12
12
 
13
- this.root.getBoundingClientRect()
13
+ this.element.getBoundingClientRect()
14
14
 
15
- this.root.classList.add('show')
15
+ this.element.classList.add('show')
16
16
  this.visible = true
17
17
 
18
18
  if (this.underlay) {
@@ -26,11 +26,11 @@ export default {
26
26
  },
27
27
 
28
28
  hide () {
29
- // console.log('hide', this.root.style.display)
29
+ // console.log('hide', this.element.style.display)
30
30
 
31
- if (!this.root) return
31
+ if (!this.element) return
32
32
 
33
- this.root.classList.remove('show')
33
+ this.element.classList.remove('show')
34
34
  this.visible = false
35
35
 
36
36
  if (this.underlay) {
@@ -43,8 +43,8 @@ export default {
43
43
 
44
44
  destroy () {
45
45
  // console.log('destroy', this.options.transition)
46
- if (this.options.transition && this.root) {
47
- this.root.classList.remove('show')
46
+ if (this.options.transition && this.element) {
47
+ this.element.classList.remove('show')
48
48
 
49
49
  if (this.underlay) {
50
50
  this.underlay.classList.remove('show')
@@ -63,9 +63,9 @@ export default {
63
63
  },
64
64
 
65
65
  removeChild () {
66
- if (this.root && this.root.parentNode) {
67
- this.root.parentNode.removeChild(this.root)
68
- this.root = null
66
+ if (this.element && this.element.parentNode) {
67
+ this.element.parentNode.removeChild(this.element)
68
+ this.element = null
69
69
  }
70
70
 
71
71
  if (this.underlay && this.underlay.parentNode) {
@@ -61,7 +61,7 @@ export default {
61
61
  }
62
62
 
63
63
  // console.log('showSearch')
64
- this.ui['filter'].root.classList.add('selected')
64
+ this.ui['filter'].element.classList.add('selected')
65
65
  this.ui['filter-input'].classList.add('show')
66
66
 
67
67
  // this.ui['search-list'].classList.add('show')
@@ -74,7 +74,7 @@ export default {
74
74
  */
75
75
  hideFilter () {
76
76
  // console.log('hideSearch')
77
- this.ui['filter'].root.classList.remove('selected')
77
+ this.ui['filter'].element.classList.remove('selected')
78
78
  this.ui['filter-input'].classList.remove('show')
79
79
  // this.ui['search-list'].classList.remove('show')
80
80
  // this.ui.body.classList.remove('hide')
@@ -154,7 +154,7 @@ export default {
154
154
 
155
155
  }
156
156
 
157
- if (this.ui.filter && this.ui.filter.root.classList.contains('selected')) {
157
+ if (this.ui.filter && this.ui.filter.element.classList.contains('selected')) {
158
158
  route = this.addParams(route, this.getFilter())
159
159
  }
160
160
 
@@ -93,7 +93,7 @@ export default {
93
93
  toggleSearch (e) {
94
94
  e.stopPropagation()
95
95
  // console.log('toggle search', this.ui.body)
96
- if (!this.ui['search-input'].root.classList.contains('show')) {
96
+ if (!this.ui['search-input'].element.classList.contains('show')) {
97
97
  this.showSearch()
98
98
  } else {
99
99
  this.hideSearch()
@@ -111,15 +111,15 @@ export default {
111
111
 
112
112
  // console.log('showSearch')
113
113
  this.mode = 'search'
114
- this.root.classList.add('search-mode')
114
+ this.element.classList.add('search-mode')
115
115
 
116
116
  if (this.ui.search) {
117
- this.ui.search.root.classList.add('selected')
117
+ this.ui.search.element.classList.add('selected')
118
118
  }
119
119
 
120
120
  if (this.ui['search-input']) {
121
121
  this.ui['search-input'].input.value = ''
122
- this.ui['search-input'].root.classList.add('show')
122
+ this.ui['search-input'].element.classList.add('show')
123
123
  this.ui['search-input'].input.focus()
124
124
  }
125
125
 
@@ -136,13 +136,13 @@ export default {
136
136
  hideSearch (notfetch) {
137
137
  // console.log('hideSearch', notfetch)
138
138
  this.mode = 'standard'
139
- this.root.classList.remove('search-mode')
139
+ this.element.classList.remove('search-mode')
140
140
 
141
141
  if (this.ui.search) {
142
- this.ui.search.root.classList.remove('selected')
142
+ this.ui.search.element.classList.remove('selected')
143
143
  }
144
144
  if (this.ui['search-input']) {
145
- this.ui['search-input'].root.classList.remove('show')
145
+ this.ui['search-input'].element.classList.remove('show')
146
146
  this.ui['search-input'].input.value = ''
147
147
  }
148
148
  // this.ui['search-list'].classList.remove('show')