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,272 +0,0 @@
1
- // module
2
- import dataset from '../view/dataset'
3
- import attach from '../module/attach'
4
- import emitter from '../module/emitter'
5
- import attributes from './module/attributes'
6
- import addClass from './module/addclass'
7
-
8
- // ui
9
- import Layout from '../layout'
10
- import Element from '../element'
11
-
12
- let defaults = {
13
- class: 'switch',
14
- attributes: ['type', 'name', 'required', 'checked'],
15
- layout: [
16
- [Element, 'input', { class: 'input', type: 'checkbox' }],
17
- [Element, 'control', { class: 'control' },
18
- [Element, 'track', { class: 'track' },
19
- [Element, 'knob', { class: 'knob' }]
20
- ]
21
- ]
22
- ],
23
- events: [
24
- ['ui.control.click', 'toggle'],
25
- // ['ui.label.click', 'toggle'],
26
- // for accessibility purpose
27
- ['ui.input.click', 'toggle'],
28
- ['ui.input.focus', 'focus'],
29
- ['ui.input.blur', 'blur']
30
- ]
31
- }
32
-
33
- class Switch {
34
- constructor (options) {
35
- this.options = Object.assign({}, defaults, options || {})
36
- Object.assign(this, emitter, attach, dataset)
37
-
38
- this.value = this.options.value
39
-
40
- this.build()
41
- this.setup()
42
- this.attach()
43
-
44
- return this
45
- }
46
-
47
- /**
48
- * build method
49
- * @return {Object} The class instance
50
- */
51
- build () {
52
- var tag = this.options.tag || 'span'
53
- this.element = document.createElement(tag)
54
- this.element.classList.add('switch')
55
-
56
- if (this.options.class !== 'switch') {
57
- addClass(this.element, this.options.class)
58
- }
59
-
60
- this.layout = new Layout(this.options.layout, this.element)
61
- this.ui = this.layout.component
62
-
63
- // console.log('ui', this.ui)
64
-
65
- this.styleAttributes()
66
-
67
- this.buildIcon()
68
- this.buildLabel()
69
-
70
- if (this.options.container) {
71
- this.options.container.appendChild(this.element)
72
- }
73
- }
74
-
75
- setup () {
76
- if (this.options.data) {
77
- dataset(this.element, this.options.data)
78
- }
79
-
80
- // console.log('attribute', this.ui.input, this.options)
81
- attributes(this.ui.input, this.options)
82
-
83
- if (this.options.checked) {
84
- this.check(true)
85
- }
86
-
87
- if (this.value) {
88
- this.element.input.setAttribute('checked', 'checked')
89
- }
90
-
91
- if (this.options.tooltip) {
92
- this.element.setAttribute('data-tooltip', this.options.tooltip)
93
- }
94
-
95
- this.ui.input.setAttribute('aria-label', this.options.name)
96
-
97
- if (this.options.case) {
98
- this.element.classList.add(this.options.case + '-case')
99
- }
100
- }
101
-
102
- buildLabel () {
103
- // console.log('buildLabel', this.options.label)
104
- if (!this.options.label) return
105
-
106
- this.ui.label = document.createElement('label')
107
- this.ui.label.classList.add('label')
108
- this.ui.label.innerHTML = this.options.label
109
-
110
- if (this.options.name) {
111
- this.ui.label.setAttribute('for', this.options.name)
112
- }
113
-
114
- this.element.insertBefore(this.ui.label, this.ui.input)
115
- }
116
-
117
- buildIcon () {
118
- if (!this.options.icon) return
119
-
120
- this.ui.icon = document.createElement('i')
121
- this.ui.icon.classList.add('icon')
122
- this.ui.icon.innerHTML = this.options.icon
123
-
124
- this.element.insertBefore(this.ui.icon, this.ui.input)
125
- }
126
-
127
- styleAttributes () {
128
- if (this.options.style) {
129
- this.element.classList.add('style-' + this.options.style)
130
- }
131
-
132
- if (this.options.size) {
133
- this.element.classList.add(this.options.size + '-size')
134
- }
135
-
136
- if (this.options.color) {
137
- this.element.classList.add('color-' + this.options.color)
138
- }
139
-
140
- if (this.options.bold) {
141
- this.element.classList.add('bold')
142
- }
143
- }
144
-
145
- /**
146
- * Setter
147
- * @param {string} prop
148
- * @param {string} value
149
- * @return {Object} The class instance
150
- */
151
- set (prop, value, silent) {
152
- switch (prop) {
153
- case 'value':
154
- this.setValue(value, silent)
155
- break
156
- case 'text':
157
- this.setValue(value)
158
- break
159
- case 'disabled':
160
- if (value === true) {
161
- this.disable()
162
- } else if (value === false) {
163
- this.enable()
164
- }
165
- break
166
- default:
167
- this.setValue(prop, value)
168
- }
169
-
170
- return this
171
- }
172
-
173
- setLabel (value) {
174
- // console.log('setLabel', value)
175
- if (this.ui.label) {
176
- this.ui.label.innerHTML = value
177
- }
178
- }
179
-
180
- setText (value) {
181
- this.setLabel(value)
182
- }
183
-
184
- get () {
185
- return this.value
186
- }
187
-
188
- /**
189
- * set switch value
190
- * @param {boolean} value [description]
191
- */
192
- getValue () {
193
- return this.value
194
- }
195
-
196
- /**
197
- * set switch value
198
- * @param {boolean} value [description]
199
- */
200
- setValue (value, silent) {
201
- // console.log('setValue', value, typeof silent, silent)
202
- this.check(value, silent)
203
- }
204
-
205
- /**
206
- * [toggle description]
207
- * @return {Object} The class instance
208
- */
209
- toggle () {
210
- // console.log('toggle')
211
- if (this.disabled) return
212
-
213
- this.focus()
214
-
215
- if (this.checked) {
216
- this.check(false)
217
- } else {
218
- this.check(true)
219
- }
220
-
221
- return this
222
- }
223
-
224
- /**
225
- * Set checkbox value
226
- * @param {boolean} value [description]
227
- */
228
- check (checked, silent) {
229
- // console.log('check', checked, silent)
230
- if (checked === true) {
231
- this.element.classList.add('is-checked')
232
- this.ui.input.checked = true
233
- this.checked = true
234
- this.value = true
235
- if (!silent) {
236
- this.emit('change', this.checked)
237
- }
238
- } else {
239
- this.element.classList.remove('is-checked')
240
- this.ui.input.checked = false
241
- this.checked = false
242
- this.value = false
243
- if (!silent) {
244
- this.emit('change', this.checked)
245
- }
246
- }
247
- return this
248
- }
249
-
250
- /**
251
- * [_onInputFocus description]
252
- * @return {?} [description]
253
- */
254
- focus () {
255
- if (this.disabled === true) return this
256
-
257
- this.element.classList.add('is-focused')
258
- if (this.ui.input !== document.activeElement) { this.ui.input.focus() }
259
- return this
260
- }
261
-
262
- /**
263
- * [_onInputBlur description]
264
- * @return {?} [description]
265
- */
266
- blur () {
267
- this.element.classList.remove('is-focused')
268
- return this
269
- }
270
- }
271
-
272
- export default Switch
@@ -1,70 +0,0 @@
1
- import addClass from './module/addclass'
2
-
3
- const defaults = {
4
- class: 'text',
5
- tag: 'span'
6
- }
7
-
8
- class Text {
9
- /**
10
- * Constructor
11
- * @param {Object} options - Component options
12
- * @return {Object} Class instance
13
- */
14
- constructor (options) {
15
- this.options = Object.assign({}, defaults, options || {})
16
-
17
- // console.log('options', this.options)
18
-
19
- this.build()
20
-
21
- return this
22
- }
23
-
24
- /**
25
- * Build Method
26
- * @return {Object} This class instance
27
- */
28
- build () {
29
- this.element = document.createElement(this.options.tag)
30
- addClass(this.element, this.options.class)
31
-
32
- if (this.options.class !== 'text') {
33
- this.element.classList.add('text')
34
- }
35
-
36
- if (this.options.text) {
37
- this.set(this.options.text)
38
- }
39
-
40
- if (this.options.container) {
41
- this.options.container.appendChild(this.element)
42
- }
43
-
44
- return this
45
- }
46
-
47
- set (text) {
48
- // console.log('set', text)
49
- if (text === undefined) return
50
-
51
- var label = this.options.label || ''
52
-
53
- if (this.options.textFirst) {
54
- this.element.innerHTML = text + label
55
- } else {
56
- this.element.innerHTML = label + text
57
- }
58
-
59
- if (this.options.spaceAfter) {
60
- this.element.innerHTML = this.element.innerHTML + ' '
61
- }
62
- }
63
-
64
- setText (text) {
65
- // console.log('setText', text)
66
- this.element.innerHTML = text
67
- }
68
- }
69
-
70
- export default Text
@@ -1,177 +0,0 @@
1
-
2
- import emitter from '../module/emitter'
3
- import attach from '../module/attach'
4
- import dataset from '../view/dataset'
5
- import attributes from './module/attributes'
6
-
7
- const defaults = {
8
- class: 'textfield',
9
- attributes: ['type', 'name', 'title', 'maxlength', 'pattern', 'min', 'max', 'placeholder', 'readonly', 'autocomplete', 'required', 'disabled'],
10
- events: [
11
- ['input.input', 'onInput'],
12
- ['input.focus', 'onFocus'],
13
- ['input.blur', 'onBlur'],
14
- ['input.click', 'onClick']
15
- ]
16
- }
17
-
18
- class Text {
19
- static isComponent () {
20
- return true
21
- }
22
- /**
23
- * Constructor
24
- * @param {Object} options - Component options
25
- * @return {Object} Class instance
26
- */
27
- constructor (options) {
28
- this.options = Object.assign({}, defaults, options || {})
29
- Object.assign(this, emitter, attach, dataset)
30
- // console.log('options', options)
31
-
32
- this.build()
33
- this.attach()
34
-
35
- return this
36
- }
37
-
38
- /**
39
- * Build Method
40
- * @return {Object} This class instance
41
- */
42
- build () {
43
- var tag = this.options.tag || 'div'
44
-
45
- this.element = document.createElement(tag)
46
- this.element.classList.add('textfield')
47
-
48
- if (this.options.class !== 'textfield') {
49
- this.element.classList.add(this.options.class)
50
- }
51
-
52
- this.buildLabel()
53
- this.buildInput()
54
-
55
- if (this.options.value) {
56
- this.set(this.options.value)
57
- }
58
-
59
- if (this.options.data) {
60
- dataset(this.element, this.options.data)
61
- }
62
-
63
- if (this.container) {
64
- this.container.appendChild(this.element)
65
- }
66
-
67
- return this
68
- }
69
-
70
- buildLabel () {
71
- if (this.options.label) {
72
- this.label = document.createElement('label')
73
- this.label.classList.add('label')
74
- this.label.innerHTML = this.options.label
75
- this.element.appendChild(this.label)
76
- }
77
- }
78
-
79
- buildInput () {
80
- let tag = 'input'
81
- if (this.options.type === 'multiline') {
82
- tag = 'textarea'
83
- }
84
- this.input = document.createElement(tag)
85
- this.input.classList.add('input')
86
- this.element.appendChild(this.input)
87
-
88
- attributes(this.input, this.options)
89
-
90
- if (this.options.focus) {
91
- this.input.focus()
92
- }
93
- }
94
-
95
- onInput (ev) {
96
- // console.log('onInput', this.value, this.input.value)
97
-
98
- this.emit('change', ev)
99
- }
100
-
101
- onFocus (ev) {
102
- this.element.classList.add('focused')
103
- this.emit('focus', ev)
104
- }
105
-
106
- onBlur (ev) {
107
- this.element.classList.remove('focused')
108
- this.emit('blur', ev)
109
- }
110
-
111
- onClick (ev) {
112
- // console.log('click')
113
- this.emit('click', ev)
114
- }
115
-
116
- /**
117
- * Setter
118
- * @param {string} prop
119
- * @param {string} value
120
- * @return {Object} The class instance
121
- */
122
- set (prop, value) {
123
- // console.log('set', this.element, prop, value)
124
- switch (prop) {
125
- case 'value':
126
- this.setValue(value)
127
- break
128
- case 'label':
129
- this.setLabel(value)
130
- break
131
- default:
132
- // console.log('prop', prop)
133
- this.setValue(prop)
134
- }
135
-
136
- return this
137
- }
138
-
139
- setValue (value) {
140
- // console.log('set', typeof value, value)
141
- if (value && value !== 'undefined') {
142
- this.value = value
143
- this.input.value = value
144
- } else {
145
- this.input.value = ''
146
- }
147
- }
148
-
149
- setLabel (value) {
150
- // console.log('setLabel', value)
151
- if (this.label) {
152
- this.label.innerHTML = value
153
- }
154
- }
155
-
156
- setText (value) {
157
- this.setLabel(value)
158
-
159
- if (this.options.placeholder) {
160
- this.input.placeholder = value
161
- }
162
- }
163
-
164
- hide () {
165
- this.element.classList.add('hide')
166
- }
167
-
168
- show () {
169
- this.element.classList.remove('hide')
170
- }
171
-
172
- get () {
173
- return this.input.value
174
- }
175
- }
176
-
177
- export default Text
package/src/tabs/setup.js DELETED
File without changes
File without changes