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
@@ -1,267 +0,0 @@
1
- import emitter from '../module/emitter'
2
- import attach from '../module/attach'
3
-
4
- import dataset from '../view/dataset'
5
-
6
- const defaults = {
7
- class: 'button',
8
- tag: 'button',
9
- styles: ['style', 'color'],
10
- stopPropagation: false,
11
- events: [
12
- ['root.click', 'click'],
13
- ['root.mousedown', 'mousedown'],
14
- ['root.mouseup', 'mouseup'],
15
- ['root.mouseleave', 'mouseup'],
16
- ['root.touchstart', 'mousedown'],
17
- ['root.touchend', 'mouseup']
18
- ]
19
-
20
- }
21
-
22
- class Button {
23
- static isComponent () {
24
- return true
25
- }
26
-
27
- /**
28
- * Constructor
29
- * @param {Object} options - Component options
30
- * @return {Object} Class instance
31
- */
32
- constructor (options) {
33
- this.options = Object.assign({}, defaults, options || {})
34
- Object.assign(this, emitter, attach)
35
- // console.log('options', options)
36
-
37
- this.init()
38
-
39
- return this
40
- }
41
-
42
- init () {
43
- this.build()
44
- this.setup()
45
- this.attach()
46
-
47
- if (this.options.container) {
48
- this.append(this.options.container)
49
- }
50
- }
51
-
52
- /**
53
- * Build Method
54
- * @return {Object} This class instance
55
- */
56
- build () {
57
- this.root = document.createElement(this.options.tag)
58
-
59
- this.element = this.root
60
-
61
- // console.log('class', this.options.class)
62
-
63
- if (this.options.class !== 'button') {
64
- this.root.setAttribute('class', 'button ' + this.options.class)
65
- } else {
66
- this.root.classList.add('button')
67
- }
68
-
69
- this.styleAttributes()
70
-
71
- this.buildIcon()
72
- this.buildLabel()
73
-
74
- if (this.options.text) {
75
- this.root.innerHTML = this.root.innerHTML + this.options.text
76
- }
77
-
78
- return this
79
- }
80
-
81
- setup () {
82
- if (this.options.data) {
83
- dataset(this.root, this.options.data)
84
- }
85
-
86
- if (this.options.type) {
87
- this.root.setAttribute('type', this.options.type)
88
- } else {
89
- this.root.setAttribute('type', 'button')
90
- }
91
-
92
- if (this.options.name) {
93
- this.root.setAttribute('name', this.options.name)
94
- }
95
-
96
- if (this.options.value) {
97
- this.root.setAttribute('value', this.options.value)
98
- }
99
-
100
- if (this.options.title) {
101
- this.root.setAttribute('title', this.options.title)
102
- }
103
-
104
- this.root.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
105
-
106
- if (this.options.tooltip) {
107
- this.root.setAttribute('data-tooltip', this.options.tooltip)
108
- }
109
-
110
- if (this.options.case) {
111
- this.root.classList.add(this.options.case + '-case')
112
- }
113
- }
114
-
115
- append (container) {
116
- container = container || this.options.container
117
- if (this.options.container) {
118
- container.appendChild(this.root)
119
- }
120
- }
121
-
122
- buildLabel () {
123
- if (!this.options.label) return
124
-
125
- if (this.options.label) {
126
- this.label = document.createElement('label')
127
- this.label.classList.add('label')
128
- this.label.innerHTML = this.options.label
129
-
130
- this.root.appendChild(this.label)
131
- }
132
- }
133
-
134
- buildIcon () {
135
- if (!this.options.icon) return
136
-
137
- if (this.options.icon) {
138
- this.icon = document.createElement('i')
139
- this.icon.classList.add('icon')
140
- this.icon.innerHTML = this.options.icon
141
-
142
- this.root.appendChild(this.icon)
143
- }
144
- }
145
-
146
- styleAttributes () {
147
- if (this.options.style) {
148
- this.root.classList.add('style-' + this.options.style)
149
- }
150
-
151
- if (this.options.size) {
152
- this.root.classList.add(this.options.size + '-size')
153
- }
154
-
155
- if (this.options.color) {
156
- this.root.classList.add('color-' + this.options.color)
157
- }
158
-
159
- if (this.options.bold) {
160
- this.root.classList.add('bold')
161
- }
162
- }
163
-
164
- /**
165
- * Setter
166
- * @param {string} prop
167
- * @param {string} value
168
- * @return {Object} The class instance
169
- */
170
- set (prop, value) {
171
- // console.log('set', this.root, prop, value)
172
- switch (prop) {
173
- case 'value':
174
- this.root.value = value
175
- break
176
- case 'label':
177
- if (this.label) {
178
- this.label.innerHTML = value
179
- }
180
- break
181
- case 'text':
182
- this.root.innerHTML = value
183
- break
184
- case 'icon':
185
- if (this.label) {
186
- this.icon.innerHTML = value
187
- }
188
- break
189
- default:
190
- // console.log('prop', prop)
191
- this.root.innerHTML = prop
192
- }
193
-
194
- return this
195
- }
196
-
197
- setLabel (value) {
198
- // console.log('setLabel', value)
199
- this.label.innerHTML = value
200
- }
201
-
202
- setText (value) {
203
- // console.log('setText', value)
204
- if (this.label) {
205
- this.setLabel(value)
206
- } else {
207
- this.root.innerHTML = value
208
- }
209
- }
210
-
211
- /**
212
- * Setter
213
- * @param {string} prop
214
- * @param {string} value
215
- * @return {Object} The class instance
216
- */
217
- get (prop, value) {
218
- switch (prop) {
219
- case 'value':
220
- return this.root.value
221
- case 'label':
222
- return this.label.innerHTML
223
- default:
224
- return this.root.value
225
- }
226
- }
227
-
228
- disable () {
229
- this.root.disabled = true
230
- }
231
-
232
- enable () {
233
- this.root.disabled = false
234
- }
235
-
236
- hide () {
237
- this.root.classList.add('hide')
238
- }
239
-
240
- show () {
241
- this.root.classList.remove('hide')
242
- }
243
-
244
- destroy () {
245
- if (this.root && this.root.parentNode) {
246
- this.root.parentNode.removeChild(this.root)
247
- }
248
- }
249
-
250
- click (ev) {
251
- if (this.options.stopPropagation === true) {
252
- ev.stopPropagation()
253
- }
254
-
255
- this.emit('click', ev)
256
- }
257
-
258
- mousedown (ev) {
259
- this.root.classList.add('pushed')
260
- }
261
-
262
- mouseup (ev) {
263
- this.root.classList.remove('pushed')
264
- }
265
- }
266
-
267
- 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.root = document.createElement(this.options.tag)
45
-
46
- if (this.options.class !== 'button') {
47
- this.root.classList.add('button')
48
- }
49
-
50
- this.root.classList.add(this.options.class)
51
- this.styleAttributes()
52
-
53
- if (this.options.text) {
54
- this.root.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.root, this.options.data)
67
- }
68
-
69
- if (this.options.type) {
70
- this.root.setAttribute('type', this.options.type)
71
- } else {
72
- this.root.setAttribute('type', 'button')
73
- }
74
-
75
- if (this.options.name) {
76
- this.root.setAttribute('name', this.options.name)
77
- }
78
-
79
- this.root.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
80
-
81
- if (this.options.tooltip) {
82
- this.root.setAttribute('data-tooltip', this.options.tooltip)
83
- }
84
-
85
- if (this.options.case) {
86
- this.root.classList.add(this.options.case + '-case')
87
- }
88
- }
89
-
90
- append (container) {
91
- if (this.options.container) {
92
- this.options.container.appendChild(this.root)
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.root.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.root.appendChild(this.label)
109
- }
110
- }
111
-
112
- styleAttributes () {
113
- if (this.options.style) {
114
- this.root.classList.add('style-' + this.options.style)
115
- }
116
-
117
- if (this.options.color) {
118
- this.root.classList.add('color-' + this.options.color)
119
- }
120
-
121
- if (this.options.bold) {
122
- this.root.classList.add('bold')
123
- }
124
- }
125
-
126
- attach () {
127
- this.root.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.root.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.root.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.root.value
170
- case 'label':
171
- return this.ui.label.innerHTML
172
- default:
173
- return this.root.value
174
- }
175
- }
176
-
177
- disable () {
178
- this.root.disabled = true
179
- }
180
-
181
- enable () {
182
- this.root.disabled = false
183
- }
184
-
185
- destroy () {
186
- this.root.parentNode.removeChild(this.root)
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.root = document.createElement(this.options.tag)
37
- this.root.classList.add(this.options.class)
38
-
39
- if (this.options.container) {
40
- this.options.container.appendChild(this.root)
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.root.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.root = document.createElement('div')
61
- this.root.classList.add('dialog')
62
-
63
- this.element = this.root
64
-
65
- if (this.options.class !== 'dialog') {
66
- this.root.classList.add(this.options.class)
67
- }
68
-
69
- if (this.options.position) {
70
- this.root.classList.add('position-' + this.options.position)
71
- }
72
-
73
- this.surface = document.createElement('div')
74
- this.surface.classList.add('surface')
75
- this.root.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.root)
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.root.classList.add('emphase')
161
- var it
162
- it = setTimeout(() => {
163
- clearTimeout(it)
164
- this.root.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