material 0.7.0 → 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 (65) hide show
  1. package/form.js +27 -0
  2. package/index.js +59 -58
  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 +155 -155
  8. package/src/calendar.js +0 -2
  9. package/src/card.js +0 -2
  10. package/src/checkbox.js +0 -2
  11. package/src/component.js +0 -2
  12. package/src/container.js +0 -2
  13. package/src/datehour.js +38 -0
  14. package/src/dialog.js +105 -152
  15. package/src/divider.js +0 -2
  16. package/src/drawer.js +0 -2
  17. package/src/{control/file.js → file.js} +15 -45
  18. package/src/form/verify.js +2 -2
  19. package/src/form.js +0 -2
  20. package/src/icon.js +0 -2
  21. package/src/image.js +39 -106
  22. package/src/item.js +0 -2
  23. package/src/{control/link.js → link.js} +13 -32
  24. package/src/list/build.js +2 -2
  25. package/src/list/collection.js +1 -1
  26. package/src/list/filter.js +2 -2
  27. package/src/list/request.js +1 -1
  28. package/src/list/search.js +5 -5
  29. package/src/list.js +29 -217
  30. package/src/loading.js +73 -0
  31. package/src/menu.js +60 -116
  32. package/src/mixin/display.js +0 -1
  33. package/src/mixin/insert.js +2 -24
  34. package/src/{control/module → module}/attributes.js +2 -2
  35. package/src/module/build.js +8 -5
  36. package/src/navigation.js +19 -0
  37. package/src/progress.js +0 -2
  38. package/src/search.js +71 -0
  39. package/src/select.js +57 -272
  40. package/src/{control/selecter.js → selecter.js} +5 -5
  41. package/src/skin/material/component/navigation.sass +1 -0
  42. package/src/skin/material/control/button.sass +10 -0
  43. package/src/slider.js +0 -2
  44. package/src/snackbar.js +72 -51
  45. package/src/switch.js +111 -103
  46. package/src/{control/switcher.js → switcher.js} +17 -20
  47. package/src/text.js +25 -74
  48. package/src/textfield.js +96 -233
  49. package/src/banner.js +0 -231
  50. package/src/control/button.js +0 -239
  51. package/src/control/button.new.js +0 -190
  52. package/src/control/datehour.js +0 -65
  53. package/src/control/dialog.js +0 -175
  54. package/src/control/image.js +0 -92
  55. package/src/control/list.js +0 -67
  56. package/src/control/loading.js +0 -128
  57. package/src/control/menu.js +0 -85
  58. package/src/control/search.js +0 -98
  59. package/src/control/select.js +0 -130
  60. package/src/control/snackbar.js +0 -91
  61. package/src/control/switch.js +0 -272
  62. package/src/control/text.js +0 -70
  63. package/src/control/textfield.js +0 -177
  64. package/src/tabs/setup.js +0 -0
  65. /package/src/{control/module → module}/addclass.js +0 -0
@@ -1,239 +0,0 @@
1
- import EventEmitter from '../mixin/emitter'
2
-
3
- import build from '../module/build'
4
- import display from '../mixin/display'
5
- import bindEvents from '../module/events'
6
-
7
- import dataset from '../module/dataset'
8
- import ripple from '../module/ripple'
9
-
10
- class Button extends EventEmitter{
11
- static isComponent () {
12
- return true
13
- }
14
-
15
- static defaults = {
16
- class: 'button',
17
- tag: 'button',
18
- modules: [build, bindEvents],
19
- styles: ['style', 'color'],
20
- ripple: false,
21
- stopPropagation: false,
22
- events: [
23
- ['element.click', 'click'],
24
- ['element.mousedown', 'mousedown'],
25
- ['element.mouseup', 'mouseup'],
26
- ['element.mouseleave', 'mouseup'],
27
- ['element.touchstart', 'mousedown'],
28
- ['element.touchend', 'mouseup']
29
- ]
30
- }
31
-
32
- /**
33
- * Constructor
34
- * @param {Object} options - Component options
35
- * @return {Object} Class instance
36
- */
37
- constructor (options) {
38
- super()
39
-
40
- this.init(options)
41
- this.build()
42
- this.setup()
43
- this.bindEvents()
44
-
45
- if (this.options.container) {
46
- this.append(this.options.container)
47
- }
48
-
49
- return this
50
- }
51
-
52
- init (options) {
53
- this.options = Object.assign({}, Button.defaults, options || {})
54
- Object.assign(this, build, display, bindEvents)
55
-
56
- }
57
-
58
- setup () {
59
- this.styleAttributes()
60
-
61
- this.buildIcon()
62
- this.buildLabel()
63
-
64
- if (this.options.text) {
65
- this.element.innerHTML = this.element.innerHTML + this.options.text
66
- }
67
-
68
- if (this.options.data) {
69
- dataset(this.element, this.options.data)
70
- }
71
-
72
- if (this.options.type) {
73
- this.element.setAttribute('type', this.options.type)
74
- } else {
75
- this.element.setAttribute('type', 'button')
76
- }
77
-
78
- if (this.options.name) {
79
- this.element.setAttribute('name', this.options.name)
80
- }
81
-
82
- if (this.options.value) {
83
- this.element.setAttribute('value', this.options.value)
84
- }
85
-
86
- if (this.options.title) {
87
- this.element.setAttribute('title', this.options.title)
88
- }
89
-
90
- this.element.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
91
-
92
- if (this.options.tooltip) {
93
- this.element.setAttribute('data-tooltip', this.options.tooltip)
94
- }
95
-
96
- if (this.options.case) {
97
- this.element.classList.add(this.options.case + '-case')
98
- }
99
- }
100
-
101
- append (container) {
102
- container = container || this.options.container
103
- if (this.options.container) {
104
- container.appendChild(this.element)
105
- }
106
- }
107
-
108
- buildLabel () {
109
- if (!this.options.label) return
110
-
111
- if (this.options.label) {
112
- this.label = document.createElement('label')
113
- this.label.classList.add('label')
114
- this.label.innerHTML = this.options.label
115
-
116
- this.element.appendChild(this.label)
117
- }
118
- }
119
-
120
- buildIcon () {
121
- if (!this.options.icon) return
122
-
123
- if (this.options.icon) {
124
- this.icon = document.createElement('i')
125
- this.icon.classList.add('icon')
126
- this.icon.innerHTML = this.options.icon
127
-
128
- this.element.appendChild(this.icon)
129
- }
130
- }
131
-
132
- styleAttributes () {
133
- if (this.options.style) {
134
- this.element.classList.add('style-' + this.options.style)
135
- }
136
-
137
- if (this.options.size) {
138
- this.element.classList.add(this.options.size + '-size')
139
- }
140
-
141
- if (this.options.color) {
142
- this.element.classList.add('color-' + this.options.color)
143
- }
144
-
145
- if (this.options.bold) {
146
- this.element.classList.add('bold')
147
- }
148
- }
149
-
150
- /**
151
- * Setter
152
- * @param {string} prop
153
- * @param {string} value
154
- * @return {Object} The class instance
155
- */
156
- set (prop, value) {
157
- // console.log('set', this.element, prop, value)
158
- switch (prop) {
159
- case 'value':
160
- this.element.value = value
161
- break
162
- case 'label':
163
- if (this.label) {
164
- this.label.innerHTML = value
165
- }
166
- break
167
- case 'text':
168
- this.element.innerHTML = value
169
- break
170
- case 'icon':
171
- if (this.icon) {
172
- this.icon.innerHTML = value
173
- }
174
- break
175
- default:
176
- // console.log('prop', prop)
177
- this.element.innerHTML = prop
178
- }
179
-
180
- return this
181
- }
182
-
183
- setLabel (value) {
184
- // console.log('setLabel', value)
185
- this.label.innerHTML = value
186
- }
187
-
188
- setText (value) {
189
- // console.log('setText', value)
190
- if (this.label) {
191
- this.setLabel(value)
192
- } else {
193
- this.element.innerHTML = value
194
- }
195
- }
196
-
197
- /**
198
- * Setter
199
- * @param {string} prop
200
- * @param {string} value
201
- * @return {Object} The class instance
202
- */
203
- get (prop, value) {
204
- switch (prop) {
205
- case 'value':
206
- return this.element.value
207
- case 'label':
208
- return this.label.innerHTML
209
- default:
210
- return this.element.value
211
- }
212
- }
213
-
214
- disable () {
215
- this.element.disabled = true
216
- }
217
-
218
- enable () {
219
- this.element.disabled = false
220
- }
221
-
222
- click (ev) {
223
- if (this.options.stopPropagation === true) {
224
- ev.stopPropagation()
225
- }
226
-
227
- this.emit('click', ev)
228
- }
229
-
230
- mousedown (ev) {
231
- this.element.classList.add('pushed')
232
- }
233
-
234
- mouseup (ev) {
235
- this.element.classList.remove('pushed')
236
- }
237
- }
238
-
239
- export default Button
@@ -1,190 +0,0 @@
1
- import emitter from '../module/emitter'
2
- import dataset from '../view/dataset'
3
-
4
- const defaults = {
5
- class: 'button',
6
- tag: 'button',
7
- styles: ['style', 'color']
8
- }
9
-
10
- class Button {
11
- static isComponent () {
12
- return true
13
- }
14
- /**
15
- * Constructor
16
- * @param {Object} options - Component options
17
- * @return {Object} Class instance
18
- */
19
- constructor (options) {
20
- this.options = Object.assign({}, defaults, options || {})
21
- Object.assign(this, emitter)
22
- // console.log('options', options)
23
-
24
- this.init()
25
-
26
- return this
27
- }
28
-
29
- init () {
30
- this.build()
31
- this.setup()
32
- this.attach()
33
-
34
- if (this.options.container) {
35
- this.append(this.options.container)
36
- }
37
- }
38
-
39
- /**
40
- * Build Method
41
- * @return {Object} This class instance
42
- */
43
- build () {
44
- this.element = document.createElement(this.options.tag)
45
-
46
- if (this.options.class !== 'button') {
47
- this.element.classList.add('button')
48
- }
49
-
50
- this.element.classList.add(this.options.class)
51
- this.styleAttributes()
52
-
53
- if (this.options.text) {
54
- this.element.innerHTML = this.options.text
55
- }
56
-
57
- if (this.options.label) {
58
- this.buildLabel()
59
- }
60
-
61
- return this
62
- }
63
-
64
- setup () {
65
- if (this.options.data) {
66
- dataset(this.element, this.options.data)
67
- }
68
-
69
- if (this.options.type) {
70
- this.element.setAttribute('type', this.options.type)
71
- } else {
72
- this.element.setAttribute('type', 'button')
73
- }
74
-
75
- if (this.options.name) {
76
- this.element.setAttribute('name', this.options.name)
77
- }
78
-
79
- this.element.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
80
-
81
- if (this.options.tooltip) {
82
- this.element.setAttribute('data-tooltip', this.options.tooltip)
83
- }
84
-
85
- if (this.options.case) {
86
- this.element.classList.add(this.options.case + '-case')
87
- }
88
- }
89
-
90
- append (container) {
91
- if (this.options.container) {
92
- this.options.container.appendChild(this.element)
93
- }
94
- }
95
-
96
- buildLabel () {
97
- if (this.options.label) {
98
- this.label = document.createElement('label')
99
- this.label.innerHTML = this.options.label
100
- this.element.appendChild(this.label)
101
- }
102
- }
103
-
104
- buildIcon () {
105
- if (this.options.icon) {
106
- this.label = document.createElement('label')
107
- this.label.innerHTML = this.options.label
108
- this.element.appendChild(this.label)
109
- }
110
- }
111
-
112
- styleAttributes () {
113
- if (this.options.style) {
114
- this.element.classList.add('style-' + this.options.style)
115
- }
116
-
117
- if (this.options.color) {
118
- this.element.classList.add('color-' + this.options.color)
119
- }
120
-
121
- if (this.options.bold) {
122
- this.element.classList.add('bold')
123
- }
124
- }
125
-
126
- attach () {
127
- this.element.addEventListener('click', (ev) => {
128
- this.emit('click', ev)
129
- })
130
- }
131
-
132
- /**
133
- * Setter
134
- * @param {string} prop
135
- * @param {string} value
136
- * @return {Object} The class instance
137
- */
138
- set (prop, value) {
139
- switch (prop) {
140
- case 'value':
141
- this.element.value = value
142
- break
143
- case 'label':
144
- if (this.ui.label) {
145
- this.ui.label.innerHTML = value
146
- }
147
- break
148
- case 'icon':
149
- if (this.ui.label) {
150
- this.ui.icon.innerHTML = value
151
- }
152
- break
153
- default:
154
- this.element.value = value
155
- }
156
-
157
- return this
158
- }
159
-
160
- /**
161
- * Setter
162
- * @param {string} prop
163
- * @param {string} value
164
- * @return {Object} The class instance
165
- */
166
- get (prop, value) {
167
- switch (prop) {
168
- case 'value':
169
- return this.element.value
170
- case 'label':
171
- return this.ui.label.innerHTML
172
- default:
173
- return this.element.value
174
- }
175
- }
176
-
177
- disable () {
178
- this.element.disabled = true
179
- }
180
-
181
- enable () {
182
- this.element.disabled = false
183
- }
184
-
185
- destroy () {
186
- this.element.parentNode.removeChild(this.element)
187
- }
188
- }
189
-
190
- export default Button
@@ -1,65 +0,0 @@
1
-
2
- const defaults = {
3
- class: 'date',
4
- tag: 'span'
5
- }
6
-
7
- /**
8
- * Class representing an image.
9
- *
10
- * @extends Date
11
- * @return {parent} The class instance
12
- * @example new Date({
13
- * date: date,
14
- * container: document.body
15
- * });
16
- */
17
- class DateHour {
18
- /**
19
- * Constructor
20
- * @param {Object} options - Component options
21
- * @return {Object} Class instance
22
- */
23
- constructor (options) {
24
- this.options = Object.assign({}, defaults, options || {})
25
-
26
- this.build()
27
-
28
- return this
29
- }
30
-
31
- /**
32
- * Build Method
33
- * @return {Object} This class instance
34
- */
35
- build () {
36
- this.element = document.createElement(this.options.tag)
37
- this.element.classList.add(this.options.class)
38
-
39
- if (this.options.container) {
40
- this.options.container.appendChild(this.element)
41
- }
42
-
43
- return this
44
- }
45
-
46
- set (date) {
47
- // console.log('set', src)
48
- var d = new Date(date)
49
- var formatted = this.format(d)
50
- this.element.innerHTML = formatted
51
- }
52
-
53
- format (date) {
54
- var hours = date.getHours()
55
- var minutes = date.getMinutes()
56
- var ampm = hours >= 12 ? 'pm' : 'am'
57
- hours = hours % 12
58
- hours = hours || 12 // the hour '0' should be '12'
59
- minutes = minutes < 10 ? '0' + minutes : minutes
60
- var strTime = hours + ':' + minutes + ' ' + ampm
61
- return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear() + ' ' + strTime
62
- }
63
- }
64
-
65
- export default DateHour
@@ -1,175 +0,0 @@
1
- // dialog related modules
2
- import emitter from '../module/emitter'
3
- import attach from '../module/attach'
4
- import display from '../view/display'
5
-
6
- import Element from '../element'
7
- import Text from './text'
8
- import Button from './button'
9
- import Layout from '../layout'
10
-
11
- let defaults = {
12
- class: 'dialog',
13
- close: true,
14
- layout: [
15
- [Element, 'head', { class: 'head' },
16
- [Text, 'title', { class: 'title' }],
17
- [Button, 'close', { class: 'close' }]
18
- ],
19
- [Element, 'body', { class: 'body' },
20
- [Text, 'content', { class: 'content' }]
21
- ],
22
- [Element, 'foot', { class: 'foot' },
23
- [Element, { class: 'divider' }],
24
- [Button, 'ok', { class: 'ok', text: 'Ok', color: 'primary' }]
25
- ]
26
- ],
27
- events: [
28
- ['element.click', 'onClickRoot'],
29
- ['surface.click', 'onClick'],
30
- ['ui.ok.click', 'ok'],
31
- ['ui.cancel.click', 'cancel'],
32
- ['ui.close.click', 'close']
33
- ]
34
- }
35
-
36
- class Dialog {
37
- /**
38
- * Constructor
39
- * @param {Object} options - Component options
40
- * @return {Object} Class instance
41
- */
42
- constructor (options) {
43
- this.options = Object.assign({}, defaults, options || {})
44
-
45
- // implement modules
46
- Object.assign(this, emitter, attach, display)
47
-
48
- this.build()
49
- this.render()
50
- this.attach()
51
-
52
- return this
53
- }
54
-
55
- /**
56
- * build the component using the super method
57
- * @return {Object} The class instance
58
- */
59
- build () {
60
- this.element = document.createElement('div')
61
- this.element.classList.add('dialog')
62
-
63
- this.element = this.element
64
-
65
- if (this.options.class !== 'dialog') {
66
- this.element.classList.add(this.options.class)
67
- }
68
-
69
- if (this.options.position) {
70
- this.element.classList.add('position-' + this.options.position)
71
- }
72
-
73
- this.surface = document.createElement('div')
74
- this.surface.classList.add('surface')
75
- this.element.appendChild(this.surface)
76
-
77
- this.layout = new Layout(this.options.layout, this.surface)
78
- this.ui = this.layout.component
79
-
80
- if (this.options.container) {
81
- this.options.container.appendChild(this.element)
82
- }
83
-
84
- if (this.options.display === 'show') {
85
- this.show()
86
- }
87
- }
88
-
89
- render () {
90
- if (this.options.title && this.ui.title) {
91
- this.ui.title.set(this.options.title)
92
- }
93
-
94
- if (this.options.content && this.ui.content) {
95
- this.ui.content.set(this.options.content)
96
- }
97
-
98
- if (this.options.cancel && this.ui.cancel) {
99
- this.ui.cancel.set('text', this.options.cancel)
100
- }
101
-
102
- if (this.options.ok && this.ui.ok) {
103
- this.ui.ok.set('text', this.options.ok)
104
- }
105
-
106
- if (this.options.target) {
107
- this.setPosition()
108
- }
109
- }
110
-
111
- setPosition () {
112
- var coord = this.options.target.getBoundingClientRect()
113
- var surface_coord = this.surface.getBoundingClientRect()
114
-
115
- if (this.options.position === 'right') {
116
- this.surface.style.top = coord.top + 'px'
117
- this.surface.style.left = coord.left + coord.width // surface_coord.width + 'px'
118
- } else {
119
- this.surface.style.top = coord.top + 'px'
120
- this.surface.style.left = coord.left - surface_coord.width + 'px'
121
- }
122
- }
123
-
124
- ok () {
125
- this.emit('ok')
126
- if (this.options.close) {
127
- this.destroy()
128
- }
129
- }
130
-
131
- cancel () {
132
- this.emit('cancel')
133
-
134
- if (this.options.close) {
135
- this.destroy()
136
- }
137
- }
138
-
139
- close () {
140
- // this.hide()
141
-
142
- if (this.options.close) {
143
- this.destroy()
144
- }
145
- }
146
-
147
- onClick (e) {
148
- e.stopPropagation()
149
- }
150
-
151
- onClickRoot (e) {
152
- // console.log('onClickRoot')
153
- e.stopPropagation()
154
- if (!this.options.modal) {
155
- this.destroy()
156
- }
157
- }
158
-
159
- emphase () {
160
- this.element.classList.add('emphase')
161
- var it
162
- it = setTimeout(() => {
163
- clearTimeout(it)
164
- this.element.classList.remove('emphase')
165
- }, 100)
166
- }
167
-
168
- set (prop, value) {
169
- if (this.ui[prop]) {
170
- this.ui[prop].set(value)
171
- }
172
- }
173
- }
174
-
175
- export default Dialog