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,92 +0,0 @@
1
-
2
- const defaults = {
3
- class: 'image',
4
- tag: 'div',
5
- format: 'thumb'
6
- }
7
-
8
- /**
9
- * Class representing an image.
10
- *
11
- * @extends Image
12
- * @return {parent} The class instance
13
- * @example new Image({
14
- * src: {
15
- * filename: 'image.png',
16
- * url: 'exmaple.com/image/'
17
- * format: ['thumbs/', 'medium/', 'large/'],
18
- * },
19
- * container: document.body
20
- * });
21
- */
22
- class Image {
23
- /**
24
- * Constructor
25
- * @param {Object} options - Component options
26
- * @return {Object} Class instance
27
- */
28
- constructor (options) {
29
- this.options = Object.assign({}, defaults, options || {})
30
-
31
- this.build()
32
-
33
- return this
34
- }
35
-
36
- /**
37
- * Build Method
38
- * @return {Object} This class instance
39
- */
40
- build () {
41
- this.root = document.createElement(this.options.tag)
42
- this.root.classList.add(this.options.class)
43
- if (this.options.class !== 'image') {
44
- this.root.classList.add('image')
45
- }
46
-
47
- if (this.options.container) {
48
- this.options.container.appendChild(this.root)
49
- }
50
-
51
- return this
52
- }
53
-
54
- set (src) {
55
- // console.log('set', src)
56
- if (!src) {
57
- this.root.style.backgroundImage = ''
58
- } else {
59
- var url = null
60
-
61
- if (src.format) {
62
- var format = this.sanitize(src.format)
63
-
64
- if (format.length > 0) {
65
- var index = format.indexOf(this.options.format)
66
- if (index === -1) {
67
- format = src.format[0] + '/'
68
- } else {
69
- format = this.options.format + '/'
70
- }
71
- }
72
-
73
- url = src.url + format
74
- } else {
75
- url = src.url
76
- }
77
-
78
- this.root.style.backgroundImage = 'url(' + url + src.filename + ')'
79
- }
80
- }
81
-
82
- sanitize (formats) {
83
- var a = []
84
- for (var i = 0; i < formats.length; i++) {
85
- var format = formats[i].replace(/\/$/, '')
86
- a.push(format)
87
- }
88
- return a
89
- }
90
- }
91
-
92
- export default Image
@@ -1,69 +0,0 @@
1
- 'use strict'
2
-
3
- const defaults = {
4
- class: 'link',
5
- tag: 'a'
6
- }
7
-
8
- class Link {
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
- this.build()
18
-
19
- return this
20
- }
21
-
22
- /**
23
- * Build Method
24
- * @return {Object} This class instance
25
- */
26
- build () {
27
- this.root = document.createElement(this.options.tag)
28
- this.root.classList.add(this.options.class)
29
-
30
- if (this.options.class !== 'link') {
31
- this.root.classList.add('link')
32
- }
33
-
34
- if (this.options.link) {
35
- this.set(this.options.link)
36
- }
37
-
38
- if (this.options.target !== 'blank') {
39
- this.root.target = this.options.target
40
- }
41
-
42
- if (this.options.container) {
43
- this.options.container.appendChild(this.root)
44
- }
45
-
46
- if (this.options.text) {
47
- this.root.innerHTML = this.options.text
48
- }
49
-
50
- return this
51
- }
52
-
53
- set (link) {
54
- // console.log('set', text)
55
- if (link === undefined) return
56
-
57
- if (this.options.target === 'blank') {
58
- this.root.href = '#'
59
- this.root.addEventListener('click', () => {
60
- window.open(link)
61
- return false
62
- })
63
- } else {
64
- this.root.href = link
65
- }
66
- }
67
- }
68
-
69
- export default Link
@@ -1,67 +0,0 @@
1
- // menu related modules
2
- import emitter from '../module/emitter'
3
- import attach from '../module/attach'
4
- import build from '../module/build'
5
- import display from '../module/display'
6
-
7
- import Layout from '../layout'
8
- import Element from '../element'
9
- import Button from './text'
10
-
11
- const defaults = {
12
- class: 'list',
13
- layout: [
14
- [Element, 'main', { tag: 'ul' }]
15
- ],
16
- item: [Text, { tag: 'li' }],
17
- events: [
18
- ['ui.main.click', 'select']
19
- ]
20
- }
21
-
22
- class List {
23
- /**
24
- * Constructor
25
- * @param {Object} options - Component options
26
- * @return {Object} Class instance
27
- */
28
- constructor (options) {
29
- this.options = Object.assign({}, defaults, options || {})
30
- // implement modules
31
- Object.assign(this, emitter, build, attach, display)
32
-
33
- this.build()
34
-
35
- return this
36
- }
37
-
38
- add (items) {
39
- for (var i = 0; i < list.length; i++) {
40
- if (i < list.length - 1) {
41
- text = text + list[i] + this.options.seprator
42
- } else {
43
- text = text + list[i]
44
- }
45
- }
46
-
47
- // console.log('set', text)
48
- if (text === undefined) return
49
-
50
- var label = this.options.label || ''
51
-
52
- this.root.innerHTML = label + text
53
-
54
- if (this.options.spaceAfter) {
55
- this.root.innerHTML = this.root.innerHTML + ' '
56
- }
57
- }
58
-
59
- select()
60
-
61
- setText (text) {
62
- // console.log('setText', text)
63
- this.root.innerHTML = text
64
- }
65
- }
66
-
67
- export default List
@@ -1,128 +0,0 @@
1
- import emitter from '../module/emitter'
2
- import attach from '../module/attach'
3
-
4
- import dataset from '../view/dataset'
5
-
6
- var defaults = {
7
- class: 'loading',
8
- tag: 'div',
9
- delay: 1000,
10
- type: 'indeterminate',
11
- circular: `<svg class="progress" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
12
- <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
13
- </svg>`
14
- }
15
-
16
- /**
17
- * The class represents an item ie for list
18
- *
19
- * @class
20
- * @return {Object} The class instance
21
- * @example new Item(object);
22
- */
23
- class Loading {
24
- static isComponent () {
25
- return true
26
- }
27
-
28
- /**
29
- * init
30
- * @return {Object} The class options
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
- /**
43
- * Setter
44
- * @param {string} prop
45
- * @param {string} value
46
- * @return {Object} The class instance
47
- */
48
- init () {
49
- this.build()
50
- // this.setup()
51
- // this.attach()
52
-
53
- if (this.options.container) {
54
- this.append(this.options.container)
55
- }
56
-
57
- return this
58
- }
59
-
60
- /**
61
- * Build function for item
62
- * @return {Object} This class instance
63
- */
64
- build (options) {
65
- this.root = document.createElement(this.options.tag)
66
- this.classify()
67
-
68
- if (this.options.type === 'circular') {
69
- this.root.innerHTML = this.options.circular
70
- } if (this.options.type === 'indeterminate') {
71
- this.bar = document.createElement(this.options.tag)
72
- this.bar.classList.add('bar')
73
- this.root.classList.add('type-indeterminate')
74
- this.root.appendChild(this.bar)
75
- }
76
-
77
- return this
78
- }
79
-
80
- classify () {
81
- if (this.options.class !== 'loading') {
82
- this.root.setAttribute('class', this.options.class + ' ' + this.options.class)
83
- } else {
84
- this.root.classList.add(this.options.class)
85
- }
86
- }
87
-
88
- append (container) {
89
- container = container || this.options.container
90
- if (this.options.container) {
91
- container.appendChild(this.root)
92
- }
93
- }
94
-
95
- set (progress) {
96
- this.bar.setAttribute('style', 'width: ' + progress)
97
- }
98
-
99
- show (delay) {
100
- delay = delay || this.options.delay
101
-
102
- clearTimeout(this.showTimeout)
103
- this.showTimeout = setTimeout(() => {
104
- this.root.classList.add('show')
105
- }, this.options.delay)
106
-
107
- this.visible = true
108
-
109
- return this
110
- }
111
-
112
- showNow () {
113
- this.root.classList.add('show')
114
-
115
- this.visible
116
-
117
- return this
118
- }
119
-
120
- hide () {
121
- clearTimeout(this.showTimeout)
122
- this.root.classList.remove('show')
123
- this.visible = false
124
- return this
125
- }
126
- };
127
-
128
- export default Loading
@@ -1,85 +0,0 @@
1
- import EventEmitter from '../component/emitter'
2
- // menu related modules
3
- import build from '../module/build'
4
- import bindEvents from '../module/events'
5
- import display from '../module/display'
6
-
7
- import Element from '../element'
8
- import Button from './button'
9
-
10
- class Menu extends EventEmitter {
11
- static defaults = {
12
- class: 'menu',
13
- transition: 200,
14
- modal: false,
15
- layout: [
16
- [Element, 'surface', { class: 'surface' },
17
- [Element, 'list', { tag: 'ul', class: 'items' }]
18
- ]
19
- ],
20
- events: [
21
- ['element.click', 'close']
22
- ]
23
- };
24
-
25
- constructor (options) {
26
- super()
27
-
28
- this.init(options)
29
- this.build(this.constructor)
30
- this.bindEvents()
31
-
32
- this.render(this.options.items)
33
- }
34
-
35
- init(options) {
36
- this.options = Object.assign({}, Menu.defaults, options || {})
37
- Object.assign(this, build, bindEvents, display)
38
- }
39
-
40
- render (items) {
41
- if (items && Array.isArray(items)) {
42
- for (var i = 0; i < items.length; i++) {
43
- this.add(items[i])
44
- }
45
- }
46
-
47
- return this
48
- }
49
-
50
- add (obj) {
51
- if (typeof obj !== 'object') return this;
52
- let item;
53
- if (obj.type === 'divider') {
54
- item = new Element({ tag: 'li', class: 'divider' })
55
- } else {
56
- obj.container = this.ui.list
57
- obj.class = 'item'
58
- item = new Button(obj).on('click', (ev) => {
59
- // console.log('select', ev.target.name)
60
- this.emit('select', ev.target.name)
61
- })
62
- }
63
-
64
- return this
65
- }
66
-
67
- position(target) {
68
- if (!target) return
69
- var offs = target.getBoundingClientRect()
70
-
71
- var offsw = this.offset = this.ui.surface.getBoundingClientRect()
72
-
73
- this.ui.surface.style.top = (offs.top - 4) + 'px'
74
- this.ui.surface.style.left = offs.left - offsw.width + offs.width + 'px'
75
-
76
- return this
77
- }
78
-
79
- close() {
80
- // console.log('close')
81
- this.destroy()
82
- }
83
- }
84
-
85
- export default Menu
@@ -1,98 +0,0 @@
1
- // search control
2
-
3
- import emitter from '../module/emitter'
4
- import Button from '../control/button'
5
- import cancel from '../skin/material/icon/cancel.svg'
6
-
7
- const defaults = {
8
- class: 'search-input',
9
- minChar: 4,
10
- iconCancel: cancel,
11
- timeout: 200
12
- }
13
-
14
- /**
15
- * Class representing a search input
16
- *
17
- * @return {parent} The class instance
18
- * @example new Search({
19
- * container: document.body
20
- * });
21
- */
22
- class Search {
23
- /**
24
- * Constructor
25
- * @param {Object} options - Component options
26
- * @return {Object} Class instance
27
- */
28
- constructor (options) {
29
- this.options = Object.assign({}, defaults, options || {})
30
- Object.assign(this, emitter)
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
- this.root = document.createElement('div')
44
- this.root.classList.add('search')
45
-
46
- if (this.options.class !== 'search') {
47
- this.root.classList.add(this.options.class)
48
- }
49
-
50
- if (this.options.icon) {
51
- this.icon = document.createElement('i')
52
- this.icon.classList.add('icon')
53
- this.icon.innerHTML = this.options.icon
54
- this.root.appendChild(this.icon)
55
- }
56
-
57
- this.input = document.createElement('input')
58
- this.input.classList.add('input')
59
- this.root.appendChild(this.input)
60
-
61
- this.cancel = new Button({
62
- container: this.root,
63
- class: 'clear',
64
- icon: this.options.iconCancel
65
- })
66
-
67
- if (this.options.container) {
68
- this.options.container.appendChild(this.root)
69
- }
70
-
71
- return this
72
- }
73
-
74
- attach () {
75
- this.input.addEventListener('input', () => {
76
- if (this.input.value.length < this.options.minChar) return
77
-
78
- clearTimeout(this.timeout)
79
-
80
- this.timeout = setTimeout(() => {
81
- this.emit('change', this.input.value)
82
- }, this.options.timeout)
83
- })
84
-
85
- this.cancel.on('click', () => {
86
- this.input.value = ''
87
- this.input.focus()
88
- this.emit('cancel')
89
- })
90
- }
91
-
92
- set (email) {
93
- this.root.innerHTML = email
94
- this.root.setAttribute('href', 'mailto:' + email)
95
- }
96
- }
97
-
98
- export default Search
@@ -1,130 +0,0 @@
1
- import emitter from '..//module/emitter'
2
- import attach from '../module/attach'
3
- import attributes from './module/attributes'
4
- import dataset from '../view/dataset'
5
-
6
- const defaults = {
7
- type: 'list', // native
8
- class: 'select',
9
- first: null,
10
- attributes: ['type', 'name', 'autocomplete', 'required']
11
- }
12
-
13
- class Select {
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, attach, dataset)
22
-
23
- this.build()
24
- this.attach()
25
-
26
- return this
27
- }
28
-
29
- /**
30
- * Build Method
31
- * @return {Object} This class instance
32
- */
33
- build () {
34
- var tag = this.options.tag || 'span'
35
- this.root = document.createElement(tag)
36
- this.root.classList.add('select')
37
-
38
- if (this.options.class !== 'select') {
39
- this.root.classList.add(this.options.class)
40
- }
41
-
42
- this.buildLabel()
43
- this.buildInput()
44
-
45
- if (this.container) {
46
- this.container.appendChild(this.root)
47
- }
48
-
49
- return this
50
- }
51
-
52
- buildLabel () {
53
- if (this.options.label) {
54
- this.label = document.createElement('span')
55
- this.label.classList.add('label')
56
- this.label.innerHTML = this.options.label
57
- this.root.appendChild(this.label)
58
- }
59
- }
60
-
61
- buildInput () {
62
- this.input = document.createElement('select')
63
- this.input.classList.add('input')
64
- this.root.appendChild(this.input)
65
-
66
- this.input.addEventListener('change', () => {
67
- // console.log('change', this.input[this.input.selectedIndex].value)
68
- this.emit('change', this.input[this.input.selectedIndex].value)
69
- })
70
-
71
- if (this.options.data) {
72
- dataset(this.data, this.options.data)
73
- }
74
-
75
- attributes(this.input, this.options)
76
-
77
- if (this.options.options) {
78
- this.setOptions(this.options.options)
79
- }
80
- }
81
-
82
- setOptions (options) {
83
- // console.log('buildCountry', this.input)
84
-
85
- var first = this.options.first
86
-
87
- if (first && first[0] && first[1]) {
88
- this.input.options[0] = new Option(first[1], first[0])
89
- }
90
-
91
- for (var i = 0; i < options.length; i++) {
92
- this.addOption(options[i][1], options[i][0])
93
- }
94
- }
95
-
96
- addOption (name, value) {
97
- // console.log('addOption', name, value)
98
- this.input.options[this.input.options.length] = new Option(name, value)
99
- }
100
-
101
- set (value) {
102
- // console.log('set', value)
103
- this.input.value = value
104
-
105
- return this
106
- }
107
-
108
- setLabel (value) {
109
- console.log('setLabel', value)
110
- if (this.label) {
111
- this.label.innerHTML = value
112
- }
113
- }
114
-
115
- setText (value) {
116
- this.setLabel(value)
117
- }
118
-
119
- get () {
120
- var value = null
121
-
122
- if (this.input[this.input.selectedIndex]) {
123
- value = this.input[this.input.selectedIndex].value
124
- }
125
-
126
- return value
127
- }
128
- }
129
-
130
- export default Select