material 0.7.0 → 0.7.2

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 (148) hide show
  1. package/README.md +1 -5
  2. package/dist/demo-bundle.js +2281 -2
  3. package/dist/demo-bundle.js.map +7 -1
  4. package/dist/demo.js +13 -13
  5. package/esbuild.js +22 -0
  6. package/esbuild.watch.js +25 -0
  7. package/form.js +27 -0
  8. package/index.js +59 -58
  9. package/list.js +35 -0
  10. package/package.json +8 -17
  11. package/src/appbar.js +7 -204
  12. package/src/badge.js +27 -0
  13. package/src/button.js +127 -177
  14. package/src/calendar.js +53 -55
  15. package/src/card.js +1 -3
  16. package/src/checkbox.js +5 -55
  17. package/src/component.js +0 -2
  18. package/src/container.js +0 -2
  19. package/src/datehour.js +38 -0
  20. package/src/dialog.js +104 -151
  21. package/src/divider.js +1 -3
  22. package/src/drawer.js +1 -19
  23. package/src/element/attribute.js +7 -10
  24. package/src/element/build.js +6 -7
  25. package/src/element/create.js +3 -6
  26. package/src/element/event.js +2 -2
  27. package/src/element/insert.js +6 -17
  28. package/src/element/observer.js +22 -0
  29. package/src/element/offset.js +2 -2
  30. package/src/element/style.js +12 -12
  31. package/src/element.js +2 -2
  32. package/src/field/email.js +9 -44
  33. package/src/field/image.js +17 -51
  34. package/src/{control/file.js → file.js} +15 -45
  35. package/src/form/build.js +7 -7
  36. package/src/form/controller.js +8 -8
  37. package/src/form/create.js +1 -1
  38. package/src/form/data.js +9 -9
  39. package/src/form/delete.js +1 -1
  40. package/src/form/render.js +9 -9
  41. package/src/form/set.js +1 -1
  42. package/src/form/submit.js +6 -6
  43. package/src/form/update.js +3 -3
  44. package/src/form/verify.js +6 -6
  45. package/src/form.js +9 -11
  46. package/src/icon.js +4 -6
  47. package/src/image.js +39 -106
  48. package/src/item.js +1 -3
  49. package/src/layout.js +14 -14
  50. package/src/{control/link.js → link.js} +13 -32
  51. package/src/list/build.js +10 -10
  52. package/src/list/click.js +3 -3
  53. package/src/list/collection.js +1 -1
  54. package/src/list/filter.js +11 -11
  55. package/src/list/image.js +3 -3
  56. package/src/list/render.js +15 -15
  57. package/src/list/request.js +8 -8
  58. package/src/list/search.js +12 -12
  59. package/src/list/select.js +18 -18
  60. package/src/list/status.js +1 -1
  61. package/src/list/update.js +6 -6
  62. package/src/list/virtual.js +20 -20
  63. package/src/list/virtual.new.js +5 -5
  64. package/src/list.js +29 -217
  65. package/src/loading.js +73 -0
  66. package/src/map/build.js +2 -2
  67. package/src/map/countries.js +8 -8
  68. package/src/map/display.js +13 -13
  69. package/src/map/focus.js +7 -7
  70. package/src/map/select.js +2 -2
  71. package/src/map/set.js +3 -3
  72. package/src/map/viewport.js +11 -11
  73. package/src/menu.js +59 -115
  74. package/src/mixin/control.js +3 -3
  75. package/src/mixin/controller.js +5 -5
  76. package/src/mixin/create.js +1 -1
  77. package/src/mixin/display.js +1 -2
  78. package/src/mixin/events.js +4 -16
  79. package/src/mixin/focus.js +1 -1
  80. package/src/mixin/icon.js +2 -2
  81. package/src/mixin/init.js +2 -2
  82. package/src/mixin/insert.js +7 -29
  83. package/src/mixin/label.js +2 -2
  84. package/src/mixin/settings.js +5 -5
  85. package/src/module/attach.js +35 -49
  86. package/src/{control/module → module}/attributes.js +4 -4
  87. package/src/module/build.js +12 -12
  88. package/src/module/classify.js +4 -4
  89. package/src/module/controller.js +5 -32
  90. package/src/module/css.js +12 -84
  91. package/src/module/dataset.js +1 -1
  92. package/src/module/dom.js +8 -3
  93. package/src/module/dot.js +4 -4
  94. package/src/module/emitter.js +1 -1
  95. package/src/module/event.js +2 -2
  96. package/src/module/events.js +29 -35
  97. package/src/module/extract.js +10 -10
  98. package/src/module/last.js +18 -0
  99. package/src/module/mediator.js +1 -13
  100. package/src/module/object.js +4 -4
  101. package/src/module/observer.js +43 -16
  102. package/src/module/remove.js +10 -10
  103. package/src/module/ripple.js +19 -24
  104. package/src/module/scrollbar.js +10 -14
  105. package/src/module/smoothscroll.js +5 -9
  106. package/src/module/utils.js +14 -23
  107. package/src/module/viewport.js +5 -5
  108. package/src/navigation.js +19 -0
  109. package/src/progress.js +1 -11
  110. package/src/search.js +66 -0
  111. package/src/select.js +58 -273
  112. package/src/{control/selecter.js → selecter.js} +42 -42
  113. package/src/selector.js +3 -3
  114. package/src/skin/material/component/navigation.sass +9 -0
  115. package/src/skin/material/control/button.sass +10 -0
  116. package/src/slider.js +1 -3
  117. package/src/snackbar.js +72 -50
  118. package/src/switch.js +111 -103
  119. package/src/{control/switcher.js → switcher.js} +28 -31
  120. package/src/tabs.js +4 -5
  121. package/src/tabview.js +26 -46
  122. package/src/text.js +25 -74
  123. package/src/textfield.js +97 -234
  124. package/src/toolbar.js +12 -12
  125. package/src/tooltip.js +7 -7
  126. package/src/tree.js +10 -66
  127. package/src/view/build.js +2 -2
  128. package/src/view/dataset.js +1 -1
  129. package/src/view.js +9 -74
  130. package/rollup.config.js +0 -34
  131. package/src/banner.js +0 -231
  132. package/src/control/button.js +0 -239
  133. package/src/control/button.new.js +0 -190
  134. package/src/control/datehour.js +0 -65
  135. package/src/control/dialog.js +0 -175
  136. package/src/control/image.js +0 -92
  137. package/src/control/list.js +0 -67
  138. package/src/control/loading.js +0 -128
  139. package/src/control/menu.js +0 -85
  140. package/src/control/module/addclass.js +0 -16
  141. package/src/control/search.js +0 -98
  142. package/src/control/select.js +0 -130
  143. package/src/control/snackbar.js +0 -91
  144. package/src/control/switch.js +0 -272
  145. package/src/control/text.js +0 -70
  146. package/src/control/textfield.js +0 -177
  147. package/src/element/ripple.js +0 -90
  148. package/src/tabs/setup.js +0 -0
package/src/select.js CHANGED
@@ -1,323 +1,108 @@
1
- 'use strict'
2
-
3
- import emitter from './module/emitter'
1
+ import EventEmitter from './mixin/emitter'
2
+ // modules
3
+ import build from './module/build'
4
4
  import attach from './module/attach'
5
+ import attributes from './module/attributes'
6
+ import dataset from './module/dataset'
5
7
 
6
- var defaults = {
7
- prefix: 'material',
8
- class: 'textfield',
9
- type: 'control',
10
- tag: 'div',
11
- events: [
12
- ['input.change', '_onChange'],
13
- ['input.focus', 'focus'],
14
- ['input.blur', 'blur'],
15
- // ['input.keypress', '_handleInputKeyPress',
16
- ['input.keyup', '_handleInputKeyPress']
17
- // ['input.mouseover', 'mouseover']
18
- // ['input.change', '_onChange']
19
- // 'input.keydown': '_handleInputKeyPress'
20
-
21
- ]
22
- }
8
+ class Select extends EventEmitter {
9
+ static defaults = {
10
+ type: 'list',
11
+ class: 'select',
12
+ first: null,
13
+ attributes: ['type', 'name', 'autocomplete', 'required']
14
+ }
23
15
 
24
- /**
25
- * Textfield class
26
- * @class
27
- */
28
- class Select {
29
- /**
30
- * Constructor
31
- * @param {Object} options - Component options
32
- * @return {Object} Class instance
33
- */
34
16
  constructor (options) {
35
- this.options = Object.assign({}, defaults, options || {})
17
+ super()
36
18
 
37
- this.init()
19
+ this.init(options)
38
20
  this.build()
39
- this.attach()
40
-
41
- return this
42
- }
43
-
44
- /**
45
- * init
46
- * @param {Object} options The class options
47
- * @return {Object} The class instance
48
- */
49
- init () {
50
- Object.assign(this, emitter, attach)
51
-
52
- this.value = this.options.value
53
-
54
- return this
55
- }
56
-
57
- mouseover () {
58
- // console.log('mouseover')
59
- }
60
-
61
- /**
62
- * [build description]
63
- * @return {Object} The class instance
64
- */
65
- build () {
66
- // create a new div as input element
67
- var tag = this.options.tag || 'div'
68
- this.element = document.createElement(tag)
69
- this.element.classList.add(this.options.prefix + '-' + this.options.class)
70
-
71
21
  this.buildLabel()
72
22
  this.buildInput()
73
- this.buildUnderline()
74
-
75
- if (this.disabled) {
76
- css.add(this.element, 'is-disabled')
77
- }
23
+ this.attach()
24
+ }
78
25
 
79
- // insert if container this.options is given
80
- if (this.options.container) {
81
- // console.log(this.name, opts.container);
82
- insert(this.element, this.options.container)
83
- }
26
+ init (options) {
27
+ this.options = Object.assign({}, Select.defaults, options || {})
28
+ Object.assign(this, build, attach, dataset)
84
29
  }
85
30
 
86
31
  buildLabel () {
87
- this.label = document.createElement('label')
88
- this.label.classList.add(this.options.class + '-label')
89
- this.element.appendChild(this.label)
90
-
91
- if (this.options.label !== false) {
92
- this.setLabel()
32
+ if (this.options.label) {
33
+ this.label = document.createElement('span')
34
+ this.label.classList.add('label')
35
+ this.label.innerHTML = this.options.label
36
+ this.element.appendChild(this.label)
93
37
  }
94
38
  }
95
39
 
96
- /**
97
- * [_initInput description]
98
- * @return {Object} The class instance
99
- */
100
40
  buildInput () {
101
41
  this.input = document.createElement('select')
102
- this.input.classList.add(this.options.class + '-input')
103
- // this.input.setAttribute('type', 'text')
42
+ this.input.classList.add('input')
104
43
  this.element.appendChild(this.input)
105
44
 
106
- if (this.options.options) {
107
- this.setOptions(this.options.options)
45
+ this.input.addEventListener('change', () => {
46
+ // console.log('change', this.input[this.input.selectedIndex].value)
47
+ this.emit('change', this.input[this.input.selectedIndex].value)
48
+ })
49
+
50
+ if (this.options.data) {
51
+ dataset(this.data, this.options.data)
108
52
  }
109
53
 
110
- // if (!this.options.value) {
111
- // this.element.classList.add('is-empty')
112
- // }
54
+ attributes(this.input, this.options)
113
55
 
114
- if (this.readonly) {
115
- this.input.setAttribute('readonly', 'readonly')
116
- this.input.setAttribute('tabindex', '-1')
56
+ if (this.options.options) {
57
+ this.setOptions(this.options.options)
117
58
  }
118
-
119
- return this.input
120
59
  }
121
60
 
122
61
  setOptions (options) {
123
- for (var i = 0; i < options.length; i++) {
124
- this.add(options[i], options[i])
125
- }
126
- }
62
+ // console.log('buildCountry', this.input)
127
63
 
128
- /**
129
- * _initUnderline
130
- * @return {Object} The class instance
131
- */
132
- buildUnderline () {
133
- this.underline = document.createElement('span')
134
- this.underline.classList.add(this.options.class + '-underline')
135
- this.element.appendChild(this.underline)
136
- }
64
+ const first = this.options.first
137
65
 
138
- /**
139
- * Setter
140
- * @param {string} prop
141
- * @param {string} value
142
- */
143
- set (prop, value) {
144
- switch (prop) {
145
- case 'value':
146
- this.setValue(value)
147
- break
148
- case 'label':
149
- this.setLabel(value)
150
- break
151
- case 'disabled':
152
- if (value === true) {
153
- this.disable()
154
- } else if (value === false) {
155
- this.enable()
156
- }
157
- break
158
- default:
159
- this.setValue(prop)
66
+ if (first && first[0] && first[1]) {
67
+ this.input.options[0] = new Option(first[1], first[0])
160
68
  }
161
69
 
162
- return this
163
- }
164
-
165
- /**
166
- * [buildLabel description]
167
- * @return {Object} The class instance
168
- */
169
- setLabel (label) {
170
- label = label || this.options.label
171
- var text
172
-
173
- if (label === null || label === false) {
174
- text = ''
175
- } else if (this.options.label) {
176
- text = label
177
- } else {
178
- text = this.options.name
70
+ for (let i = 0; i < options.length; i++) {
71
+ this.addOption(options[i][1], options[i][0])
179
72
  }
180
-
181
- this.label.textContent = text
182
73
  }
183
74
 
184
- disable () {
185
- this.disabled = true
186
-
187
- this.input.setAttribute('disabled', 'disabled')
188
- this.element.classList.add('is-disabled')
189
- return this
75
+ addOption (name, value) {
76
+ // console.log('addOption', name, value)
77
+ this.input.options[this.input.options.length] = new Option(name, value)
190
78
  }
191
79
 
192
- enable () {
193
- this.disabled = false
80
+ set (value) {
81
+ // console.log('set', value)
82
+ this.input.value = value
194
83
 
195
- this.element.input.removeAttribute('disabled')
196
- this.element.classList.remove('is-disabled')
197
84
  return this
198
85
  }
199
86
 
200
- /**
201
- * Getter
202
- * @param {string} prop
203
- * @param {string} value
204
- */
205
- get (prop) {
206
- var value
207
-
208
- switch (prop) {
209
- case 'value':
210
- value = this.getValue()
211
- break
212
- case 'name':
213
- value = this.name
214
- break
215
- default:
216
- return this.getValue()
87
+ setLabel (value) {
88
+ // console.log('setLabel', value)
89
+ if (this.label) {
90
+ this.label.innerHTML = value
217
91
  }
218
-
219
- return value
220
- }
221
-
222
- /**
223
- * [getValue description]
224
- * @return {Object} The class instance
225
- */
226
- getValue () {
227
- // console.log('getValue', this);
228
- return this.input.value
229
- }
230
-
231
- /**
232
- * [setValue description]
233
- * @param {string} value [description]
234
- */
235
- setValue (value) {
236
- // console.log('setValue', this.options.name, value)
237
- this.input.value = value
238
-
239
- if (value) {
240
- this.element.classList.remove('is-empty')
241
- } else {
242
- this.element.classList.add('is-empty')
243
- }
244
-
245
- this.emit('change', value)
246
92
  }
247
93
 
248
- _onChange (ev) {
249
- // console.log('change', ev)
250
-
251
- this.emit('change', ev.target.value)
252
- }
253
-
254
- /**
255
- * [_initValue description]
256
- * @return {Object} The class instance
257
- */
258
- _initValue () {
259
- var opts = this.options
260
-
261
- // create a new div as input element
262
- if (opts.value) {
263
- this.setValue(opts.value)
264
- }
94
+ setText (value) {
95
+ this.setLabel(value)
265
96
  }
266
97
 
267
- /**
268
- * [_onFocus description]
269
- * @return {Object} The class instance
270
- */
271
- _handleInputKeyPress (e) {
272
- // console.log('_handleInputKeyPress', e);
98
+ get () {
99
+ let value = null
273
100
 
274
- if (this.get('value') === '') {
275
- this.element.classList.add('is-empty')
276
- } else {
277
- this.element.classList.remove('is-empty')
101
+ if (this.input[this.input.selectedIndex]) {
102
+ value = this.input[this.input.selectedIndex].value
278
103
  }
279
104
 
280
- this.emit('change', this.getValue())
281
- }
282
-
283
- add (key, value, selected) {
284
- selected = selected || false
285
- var select = this.input
286
- select.options[select.options.length] = new Option(value, key, selected, selected)
287
- }
288
-
289
- /**
290
- * focus method
291
- * @return {?} [description]
292
- */
293
- focus () {
294
- if (this.disabled === true) return this
295
-
296
- this.element.classList.add('is-focused')
297
- if (this.input !== document.activeElement) { this.input.focus() }
298
- return this
299
- }
300
-
301
- /**
302
- * blur method
303
- * @return {?} [description]
304
- */
305
- blur () {
306
- this.element.classList.remove('is-focused')
307
- return this
308
- }
309
- /**
310
- * [setError description]
311
- * @param {string} error Error description
312
- */
313
- setError (error) {
314
- if (error) {
315
- this.addClass('field-error')
316
- if (this.error) { this.error.set('html', error) }
317
- } else {
318
- if (this.error) { this.removeClass('field-error') }
319
- if (this.error) { this.error.set('html', '') }
320
- }
105
+ return value
321
106
  }
322
107
  }
323
108
 
@@ -1,52 +1,50 @@
1
- import emitter from '..//module/emitter'
2
- import attach from '../module/attach'
3
- import dataset from '../view/dataset'
1
+ import EventEmitter from './mixin/emitter'
2
+ // modules
3
+ import attach from './module/attach'
4
+ import dataset from './module/dataset'
4
5
  import attributes from './module/attributes'
5
- import addClass from './module/addclass'
6
-
7
- // ui
8
- import Layout from '../layout'
9
- import Element from '../element'
6
+ import * as css from './module/css'
7
+ // components
8
+ import Layout from './layout'
9
+ import Element from './element'
10
10
  import Button from './button'
11
11
 
12
- const defaults = {
13
- class: 'selecter',
14
- first: null,
15
- attributes: ['type', 'name', 'autocomplete', 'required'],
16
- layout: [
17
- [Element, 'label', { tag: 'label', class: 'label' }],
18
- [Element, 'value', { tag: 'value', class: 'value' }],
19
- [Element, 'input', { tag: 'input', type: 'text', class: 'input' }],
20
- [Element, 'list', { class: 'list' },
21
- [Element, 'head', { class: 'head' },
22
- [Element, 'title', { class: 'title' }],
23
- [Button, 'close', { class: 'close' }]
24
- ],
25
- [Element, 'body', { class: 'body' }]
12
+ class Selecter extends EventEmitter {
13
+ static defaults = {
14
+ class: 'selecter',
15
+ first: null,
16
+ attributes: ['type', 'name', 'autocomplete', 'required'],
17
+ layout: [
18
+ [Element, 'label', { tag: 'label', class: 'label' }],
19
+ [Element, 'value', { tag: 'value', class: 'value' }],
20
+ [Element, 'input', { tag: 'input', type: 'text', class: 'input' }],
21
+ [Element, 'list', { class: 'list' },
22
+ [Element, 'head', { class: 'head' },
23
+ [Element, 'title', { class: 'title' }],
24
+ [Button, 'close', { class: 'close' }]
25
+ ],
26
+ [Element, 'body', { class: 'body' }]
27
+ ]
28
+ ],
29
+ events: [
30
+ ['ui.value.click', 'showList'],
31
+ ['ui.list.click', 'select'],
32
+ ['ui.close.click', 'hideList']
26
33
  ]
27
- ],
28
- events: [
29
- ['ui.value.click', 'showList'],
30
- ['ui.list.click', 'select'],
31
- ['ui.close.click', 'hideList']
32
- ]
33
- }
34
+ }
34
35
 
35
- class Selecter {
36
- /**
37
- * Constructor
38
- * @param {Object} options - Component options
39
- * @return {Object} Class instance
40
- */
41
36
  constructor (options) {
42
- this.options = Object.assign({}, defaults, options || {})
43
- Object.assign(this, emitter, attach, dataset)
37
+ super()
44
38
 
39
+ this.init(options)
45
40
  this.build()
46
41
  this.setup()
47
42
  this.attach()
43
+ }
48
44
 
49
- return this
45
+ init (options) {
46
+ this.options = Object.assign({}, Selecter.defaults, options || {})
47
+ Object.assign(this, attach, dataset)
50
48
  }
51
49
 
52
50
  setup () {
@@ -75,17 +73,18 @@ class Selecter {
75
73
  this.element.classList.add(this.options.case + '-case')
76
74
  }
77
75
  }
76
+
78
77
  /**
79
78
  * build method
80
79
  * @return {Object} The class instance
81
80
  */
82
81
  build () {
83
- var tag = this.options.tag || 'span'
82
+ const tag = this.options.tag || 'span'
84
83
  this.element = document.createElement(tag)
85
84
  this.element.classList.add('selecter')
86
85
 
87
86
  if (this.options.class !== 'selecter') {
88
- addClass(this.element, this.options.class)
87
+ css.add(this.element, this.options.class)
89
88
  }
90
89
 
91
90
  this.layout = new Layout(this.options.layout, this.element)
@@ -138,9 +137,9 @@ class Selecter {
138
137
 
139
138
  // console.log('list', list)
140
139
 
141
- for (var i = 0; i < list.length; i++) {
140
+ for (let i = 0; i < list.length; i++) {
142
141
  // if (list.indexOf(list[i][0]) > -1) {
143
- var item = document.createElement('div')
142
+ const item = document.createElement('div')
144
143
  item.classList.add('item')
145
144
  item.innerHTML = list[i][1]
146
145
  item.dataset.value = list[i][0]
@@ -169,6 +168,7 @@ class Selecter {
169
168
  this.element.classList.add('bold')
170
169
  }
171
170
  }
171
+
172
172
  showList () {
173
173
  // console.log('showList')
174
174
 
package/src/selector.js CHANGED
@@ -121,8 +121,8 @@ class Selector {
121
121
  update (target) {
122
122
  target = target || this.target
123
123
  if (!target) return
124
- var coords = target.getBoundingClientRect()
125
- var pcoords = this.element.parentNode.getBoundingClientRect()
124
+ const coords = target.getBoundingClientRect()
125
+ const pcoords = this.element.parentNode.getBoundingClientRect()
126
126
 
127
127
  this.element.style.top = coords.top - pcoords.top + 'px'
128
128
  this.element.style.left = coords.left - pcoords.left + 'px'
@@ -158,7 +158,7 @@ class Selector {
158
158
  const offsetY = this.element.getBoundingClientRect().y
159
159
  const element = document.body
160
160
 
161
- var ratio = parseInt(this.element.style.width, 10) / parseInt(this.element.style.height, 10)
161
+ const ratio = parseInt(this.element.style.width, 10) / parseInt(this.element.style.height, 10)
162
162
 
163
163
  this.border.setPointerCapture(ev.pointerId)
164
164
 
@@ -0,0 +1,9 @@
1
+ .navigation
2
+ flex: none
3
+ display: flex
4
+ flex-direction: column
5
+ width: 12px
6
+ background-color: #3a3a3a
7
+ margin: 0
8
+ overflow: hidden
9
+ transition: 0.1s linear width
@@ -123,3 +123,13 @@
123
123
  background-color: rgba(0, 0, 0, .1)
124
124
  &:focus
125
125
  background-color: rgba(0, 0, 0, .1)
126
+
127
+ .ripple
128
+ opacity: 1
129
+ pointer-events: none
130
+ z-index: 1
131
+ position: absolute
132
+ background-color: rgba(255, 255, 255, 0.1)
133
+ height: 5px
134
+ width: 5px
135
+ border-radius: 50%
package/src/slider.js CHANGED
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  import init from './mixin/init'
4
2
  import build from './element/build'
5
3
  import control from './mixin/control'
@@ -10,7 +8,7 @@ import offset from './element/offset'
10
8
  import classify from './module/classify'
11
9
  // import control from './control';
12
10
  import attach from './module/attach'
13
- import css from './module/css'
11
+ import * as css from './module/css'
14
12
  import emitter from './module/emitter'
15
13
 
16
14
  import icon from './skin/material/icon/pin.svg'