material 0.7.1 → 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 (122) 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/package.json +7 -20
  8. package/src/badge.js +1 -1
  9. package/src/button.js +50 -100
  10. package/src/calendar.js +53 -53
  11. package/src/card.js +1 -1
  12. package/src/checkbox.js +5 -53
  13. package/src/datehour.js +7 -7
  14. package/src/dialog.js +5 -5
  15. package/src/divider.js +1 -1
  16. package/src/drawer.js +1 -17
  17. package/src/element/attribute.js +7 -10
  18. package/src/element/build.js +6 -7
  19. package/src/element/create.js +3 -6
  20. package/src/element/event.js +2 -2
  21. package/src/element/insert.js +6 -17
  22. package/src/element/observer.js +22 -0
  23. package/src/element/offset.js +2 -2
  24. package/src/element/style.js +12 -12
  25. package/src/element.js +2 -2
  26. package/src/field/email.js +9 -44
  27. package/src/field/image.js +17 -51
  28. package/src/file.js +1 -1
  29. package/src/form/build.js +7 -7
  30. package/src/form/controller.js +8 -8
  31. package/src/form/create.js +1 -1
  32. package/src/form/data.js +9 -9
  33. package/src/form/delete.js +1 -1
  34. package/src/form/render.js +9 -9
  35. package/src/form/set.js +1 -1
  36. package/src/form/submit.js +6 -6
  37. package/src/form/update.js +3 -3
  38. package/src/form/verify.js +4 -4
  39. package/src/form.js +9 -9
  40. package/src/icon.js +4 -4
  41. package/src/image.js +7 -7
  42. package/src/item.js +1 -1
  43. package/src/layout.js +14 -14
  44. package/src/link.js +1 -1
  45. package/src/list/build.js +8 -8
  46. package/src/list/click.js +3 -3
  47. package/src/list/filter.js +11 -11
  48. package/src/list/image.js +3 -3
  49. package/src/list/render.js +15 -15
  50. package/src/list/request.js +7 -7
  51. package/src/list/search.js +9 -9
  52. package/src/list/select.js +18 -18
  53. package/src/list/status.js +1 -1
  54. package/src/list/update.js +6 -6
  55. package/src/list/virtual.js +20 -20
  56. package/src/list/virtual.new.js +5 -5
  57. package/src/list.js +8 -8
  58. package/src/map/build.js +2 -2
  59. package/src/map/countries.js +8 -8
  60. package/src/map/display.js +13 -13
  61. package/src/map/focus.js +7 -7
  62. package/src/map/select.js +2 -2
  63. package/src/map/set.js +3 -3
  64. package/src/map/viewport.js +11 -11
  65. package/src/menu.js +12 -12
  66. package/src/mixin/control.js +3 -3
  67. package/src/mixin/controller.js +5 -5
  68. package/src/mixin/create.js +1 -1
  69. package/src/mixin/display.js +1 -1
  70. package/src/mixin/events.js +4 -16
  71. package/src/mixin/focus.js +1 -1
  72. package/src/mixin/icon.js +2 -2
  73. package/src/mixin/init.js +2 -2
  74. package/src/mixin/insert.js +5 -5
  75. package/src/mixin/label.js +2 -2
  76. package/src/mixin/settings.js +5 -5
  77. package/src/module/attach.js +35 -49
  78. package/src/module/attributes.js +2 -2
  79. package/src/module/build.js +7 -10
  80. package/src/module/classify.js +4 -4
  81. package/src/module/controller.js +5 -32
  82. package/src/module/css.js +12 -84
  83. package/src/module/dataset.js +1 -1
  84. package/src/module/dom.js +8 -3
  85. package/src/module/dot.js +4 -4
  86. package/src/module/emitter.js +1 -1
  87. package/src/module/event.js +2 -2
  88. package/src/module/events.js +29 -35
  89. package/src/module/extract.js +10 -10
  90. package/src/module/last.js +18 -0
  91. package/src/module/mediator.js +1 -13
  92. package/src/module/object.js +4 -4
  93. package/src/module/observer.js +43 -16
  94. package/src/module/remove.js +10 -10
  95. package/src/module/ripple.js +19 -24
  96. package/src/module/scrollbar.js +10 -14
  97. package/src/module/smoothscroll.js +5 -9
  98. package/src/module/utils.js +14 -23
  99. package/src/module/viewport.js +5 -5
  100. package/src/progress.js +1 -9
  101. package/src/search.js +24 -29
  102. package/src/select.js +6 -6
  103. package/src/selecter.js +39 -39
  104. package/src/selector.js +3 -3
  105. package/src/skin/material/component/navigation.sass +9 -1
  106. package/src/slider.js +1 -1
  107. package/src/snackbar.js +8 -7
  108. package/src/switch.js +1 -1
  109. package/src/switcher.js +15 -15
  110. package/src/tabs.js +4 -5
  111. package/src/tabview.js +26 -46
  112. package/src/text.js +1 -1
  113. package/src/textfield.js +1 -1
  114. package/src/toolbar.js +12 -12
  115. package/src/tooltip.js +7 -7
  116. package/src/tree.js +10 -66
  117. package/src/view/build.js +2 -2
  118. package/src/view/dataset.js +1 -1
  119. package/src/view.js +9 -74
  120. package/rollup.config.js +0 -34
  121. package/src/element/ripple.js +0 -90
  122. package/src/module/addclass.js +0 -16
package/dist/demo.js CHANGED
@@ -1,5 +1,3 @@
1
- console.log('demo')
2
-
3
1
  import {
4
2
  Button,
5
3
  Component,
@@ -35,8 +33,10 @@ import iconApps from './icon/apps.svg'
35
33
  import iconStar from './icon/star.svg'
36
34
  import iconHappy from './icon/happy.svg'
37
35
 
36
+ console.log('demo')
37
+
38
38
  console.log('log')
39
- var list = [{
39
+ const list = [{
40
40
  text: 'One',
41
41
  name: 'one'
42
42
  }, {
@@ -51,7 +51,7 @@ var list = [{
51
51
  }]
52
52
 
53
53
  document.addEventListener('DOMContentLoaded', function () {
54
- var layout = new Layout([Component, 'demo', { display: 'flex', direction: 'vertical' },
54
+ const layout = new Layout([Component, 'demo', { display: 'flex', direction: 'vertical' },
55
55
  [Component, 'head', { display: 'flex', direction: 'horizontal' },
56
56
  [Toolbar, 'toolbar', { flex: 1, display: 'flex', direction: 'horizontal' },
57
57
  [Button, 'menu-navi', { icon: iconMenu, type: 'action' }],
@@ -67,7 +67,7 @@ document.addEventListener('DOMContentLoaded', function () {
67
67
  ],
68
68
  [List, 'navi-list', { theme: 'dark' }]
69
69
  ],
70
- [Tabs, 'tabs', { color: 'primary', list: list, flex: 'none' }],
70
+ [Tabs, 'tabs', { color: 'primary', list, flex: 'none' }],
71
71
  [Container, 'body', { flex: '1' },
72
72
  [Container, 'container-components', { },
73
73
  [Text, 'text', { text: 'Components', type: 'title' }]
@@ -75,7 +75,7 @@ document.addEventListener('DOMContentLoaded', function () {
75
75
  // Buttons
76
76
  [Card, 'buttons', { },
77
77
  [Toolbar, 'toolbar-buttons', {},
78
- [Text, 'buttons-title', { text: 'Buttons'}]
78
+ [Text, 'buttons-title', { text: 'Buttons' }]
79
79
  ],
80
80
  [Container, 'button-body', {},
81
81
  [Button, 'first', { text: 'Flat' }],
@@ -88,7 +88,7 @@ document.addEventListener('DOMContentLoaded', function () {
88
88
  // Buttons
89
89
  [Card, 'buttons', { },
90
90
  [Toolbar, 'toolbar-buttons', {},
91
- [Text, 'buttons-title', { text: 'Floating Buttons'}]
91
+ [Text, 'buttons-title', { text: 'Floating Buttons' }]
92
92
  ],
93
93
  [Container, 'button-body', {},
94
94
  [Button, 'fifth', { icon: iconStar, type: 'floating', color: 'primary' }],
@@ -99,7 +99,7 @@ document.addEventListener('DOMContentLoaded', function () {
99
99
  ],
100
100
  [Card, 'checkboxes', { },
101
101
  [Toolbar, 'toolbar', {},
102
- [Text, 'checkbox-title', { text: 'Checkboxes'}]
102
+ [Text, 'checkbox-title', { text: 'Checkboxes' }]
103
103
  ],
104
104
  [Container, 'checkbox-body', {},
105
105
  [Checkbox, 'checkbox', { text: 'Checkbox' }],
@@ -109,7 +109,7 @@ document.addEventListener('DOMContentLoaded', function () {
109
109
  ],
110
110
  [Card, 'switches', { },
111
111
  [Toolbar, 'switch-toolbar', {},
112
- [Text, 'switch-title', { text: 'Switches'}]
112
+ [Text, 'switch-title', { text: 'Switches' }]
113
113
  ],
114
114
  [Container, 'switch-body', {},
115
115
  [Switch, 'switch', { text: 'Switch' }],
@@ -119,7 +119,7 @@ document.addEventListener('DOMContentLoaded', function () {
119
119
  ],
120
120
  [Card, 'progress indicators', { },
121
121
  [Toolbar, 'progress-toolbar', {},
122
- [Text, 'progress-title', { text: 'Progress indicators'}]
122
+ [Text, 'progress-title', { text: 'Progress indicators' }]
123
123
  ],
124
124
  [Container, 'progress-body', {},
125
125
  [Progress, 'progress', { progress: '60%' }],
@@ -128,7 +128,7 @@ document.addEventListener('DOMContentLoaded', function () {
128
128
  ],
129
129
  [Card, 'sliders', { },
130
130
  [Toolbar, 'slider-toolbar', {},
131
- [Text, 'slider-title', { text: 'Sliders'}]
131
+ [Text, 'slider-title', { text: 'Sliders' }]
132
132
  ],
133
133
  [Container, 'slider-body', {},
134
134
  [Slider, 'slider', { text: 'Slider' }],
@@ -139,7 +139,7 @@ document.addEventListener('DOMContentLoaded', function () {
139
139
  ]
140
140
  ], document.body)
141
141
 
142
- var moreButton = layout.get('menu-more').on('click', (e) => {
142
+ const moreButton = layout.get('menu-more').on('click', (e) => {
143
143
  layout.get('more-menu').show(e)
144
144
  })
145
145
 
@@ -151,7 +151,7 @@ document.addEventListener('DOMContentLoaded', function () {
151
151
  }
152
152
  })
153
153
 
154
- var naviMenu = layout.get('menu-navi')
154
+ const naviMenu = layout.get('menu-navi')
155
155
 
156
156
  naviMenu.on('click', (e) => {
157
157
  layout.get('navi').open()
package/esbuild.js ADDED
@@ -0,0 +1,22 @@
1
+ import esbuild from 'esbuild'
2
+ import svg from 'esbuild-plugin-svg'
3
+
4
+ const outfile = './dist/demo.js'
5
+
6
+ const option = {
7
+ entryPoints: ['./dist/demo-bundle.js'],
8
+ outfile,
9
+ bundle: true,
10
+ minify: true,
11
+ sourcemap: false,
12
+ format: 'iife',
13
+ plugins: [svg()]
14
+ }
15
+
16
+ if (build.branch !== 'master') {
17
+ option.sourcemap = true
18
+ }
19
+
20
+ esbuild
21
+ .build(option)
22
+ .catch(() => process.exit(1))
@@ -0,0 +1,25 @@
1
+ import esbuild from 'esbuild'
2
+ import svg from 'esbuild-plugin-svg'
3
+ import { livereloadPlugin } from '@jgoz/esbuild-plugin-livereload'
4
+
5
+ esbuild
6
+ .build({
7
+ entryPoints: ['./dist/demo.js'],
8
+ outfile: './dist/demo-bundle.js',
9
+ bundle: true,
10
+ format: 'iife',
11
+ minify: false,
12
+ sourcemap: true,
13
+ plugins: [svg()],
14
+ watch: {
15
+ onRebuild (error, result) {
16
+ if (error) console.error('watch build failed:', error)
17
+ else {
18
+ console.log('watch build succeeded:', result)
19
+ // HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
20
+ }
21
+ }
22
+ }
23
+ }).then(result => {
24
+ console.log('watching...')
25
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "A lightweight implementation of Material Design Components - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,30 +18,17 @@
18
18
  "lightweight material design ui component es6 vanilla javascript"
19
19
  ],
20
20
  "devDependencies": {
21
- "babel-core": "^6.26.0",
22
- "babel-eslint": "^8.0.0",
23
- "babel-preset-es2015": "^6.24.1",
24
- "babel-preset-es2015-rollup": "^3.0.0",
25
- "npm-run-all": "^4.1.1",
26
- "require-dir": "^0.3.0",
27
- "rollup": "^0.49.2",
28
- "rollup-plugin-babel": "^3.0.2",
29
- "rollup-plugin-commonjs": "^8.2.0",
30
- "rollup-plugin-node-resolve": "^3.0.0",
31
- "rollup-plugin-npm": "^2.0.0",
32
- "rollup-plugin-uglify-es": "0.0.1",
33
- "standard": "^10.0.3",
34
- "uglify-es": "^3.0.28"
21
+ "esbuild": "^0.14.47",
22
+ "esbuild-plugin-svg": "^0.1.0",
23
+ "@jgoz/esbuild-plugin-livereload": "^2.0.3",
24
+ "standard": "^10.0.3"
35
25
  },
36
26
  "scripts": {
37
- "dev": "rollup -c --watch",
38
- "reload": "livereload 'dist/' -d",
27
+ "build": "node ./esbuild.js",
28
+ "build:watch": "node ./esbuild.watch.js",
39
29
  "styles": "sass --watch dist/styles/demo.sass:dist/demo.css",
40
30
  "watch": "npm-run-all --parallel reload dev",
41
31
  "docs": "jsdoc src -r -d docs",
42
32
  "test": "echo \"Error: no test specified\" && exit 1"
43
- },
44
- "dependencies": {
45
- "fs-extra": "^11.1.1"
46
33
  }
47
34
  }
package/src/badge.js CHANGED
@@ -15,7 +15,7 @@ class Badge {
15
15
  Object.assign(this, build)
16
16
  }
17
17
 
18
- set(text) {
18
+ set (text) {
19
19
  if (text) {
20
20
  this.element.innerHTML = text
21
21
  } else {
package/src/button.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import EventEmitter from './mixin/emitter'
2
-
3
2
  import build from './module/build'
4
3
  import display from './mixin/display'
5
4
  import bindEvents from './module/events'
6
-
7
5
  import dataset from './module/dataset'
8
6
  import ripple from './module/ripple'
9
7
 
10
- class Button extends EventEmitter{
8
+ const DEFAULT_TYPE = 'button'
9
+ const DEFAULT_CLASS = 'button'
10
+
11
+ class Button extends EventEmitter {
11
12
  static isComponent () {
12
13
  return true
13
14
  }
14
15
 
15
16
  static defaults = {
16
- class: 'button',
17
+ class: DEFAULT_CLASS,
17
18
  tag: 'button',
18
- modules: [build, bindEvents],
19
19
  styles: ['style', 'color'],
20
20
  ripple: true,
21
21
  stopPropagation: false,
@@ -29,11 +29,6 @@ class Button extends EventEmitter{
29
29
  ]
30
30
  }
31
31
 
32
- /**
33
- * Constructor
34
- * @param {Object} options - Component options
35
- * @return {Object} Class instance
36
- */
37
32
  constructor (options) {
38
33
  super()
39
34
 
@@ -41,112 +36,68 @@ class Button extends EventEmitter{
41
36
  this.build()
42
37
  this.setup()
43
38
  this.bindEvents()
44
-
45
- if (this.options.container) {
46
- this.append(this.options.container)
47
- }
48
-
49
- return this
50
39
  }
51
40
 
52
41
  init (options) {
53
- this.options = Object.assign({}, Button.defaults, options || {})
42
+ this.options = { ...Button.defaults, ...options }
54
43
  Object.assign(this, build, display, bindEvents)
55
-
56
44
  }
57
45
 
58
46
  setup () {
47
+ this.setAttributes()
59
48
  this.styleAttributes()
60
-
61
- this.buildIcon()
62
- this.buildLabel()
49
+ this.buildElements()
63
50
 
64
51
  if (this.options.text) {
65
52
  this.element.innerHTML = this.element.innerHTML + this.options.text
66
53
  }
54
+ }
67
55
 
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
- }
56
+ buildElements () {
57
+ this.buildIcon()
58
+ this.buildLabel()
59
+ }
95
60
 
96
- if (this.options.case) {
97
- this.element.classList.add(this.options.case + '-case')
98
- }
61
+ setAttributes () {
62
+ const { type, name, value, title, text, label, tooltip, data, case: caseOption } = this.options
99
63
 
64
+ this.element.setAttribute('type', type ?? DEFAULT_TYPE)
65
+ if (name) this.element.setAttribute('name', name)
66
+ if (value) this.element.setAttribute('value', value)
67
+ if (title) this.element.setAttribute('title', title)
68
+ this.element.setAttribute('aria-label', text ?? label ?? DEFAULT_CLASS)
69
+ if (tooltip) this.element.setAttribute('data-tooltip', tooltip)
70
+ if (data) dataset(this.element, data)
71
+ if (caseOption) this.element.classList.add(`${caseOption}-case`)
100
72
  if (this.options.ripple) ripple(this.element)
101
73
  }
102
74
 
103
- append (container) {
104
- container = container || this.options.container
105
- if (this.options.container) {
106
- container.appendChild(this.element)
107
- }
75
+ styleAttributes () {
76
+ const { style, size, color, bold } = this.options
77
+ if (style) this.element.classList.add(`style-${style}`)
78
+ if (size) this.element.classList.add(`${size}-size`)
79
+ if (color) this.element.classList.add(`color-${color}`)
80
+ if (bold) this.element.classList.add('bold')
108
81
  }
109
82
 
110
83
  buildLabel () {
111
84
  if (!this.options.label) return
112
85
 
113
- if (this.options.label) {
114
- this.label = document.createElement('label')
115
- this.label.classList.add('label')
116
- this.label.innerHTML = this.options.label
86
+ this.label = document.createElement('label')
87
+ this.label.classList.add('label')
88
+ this.label.innerHTML = this.options.label
117
89
 
118
- this.element.appendChild(this.label)
119
- }
90
+ this.element.appendChild(this.label)
120
91
  }
121
92
 
122
93
  buildIcon () {
123
94
  if (!this.options.icon) return
124
95
 
125
- if (this.options.icon) {
126
- this.icon = document.createElement('i')
127
- this.icon.classList.add('icon')
128
- this.icon.innerHTML = this.options.icon
129
-
130
- this.element.appendChild(this.icon)
131
- }
132
- }
133
-
134
- styleAttributes () {
135
- if (this.options.style) {
136
- this.element.classList.add('style-' + this.options.style)
137
- }
138
-
139
- if (this.options.size) {
140
- this.element.classList.add(this.options.size + '-size')
141
- }
142
-
143
- if (this.options.color) {
144
- this.element.classList.add('color-' + this.options.color)
145
- }
96
+ this.icon = document.createElement('i')
97
+ this.icon.classList.add('icon')
98
+ this.icon.innerHTML = this.options.icon
146
99
 
147
- if (this.options.bold) {
148
- this.element.classList.add('bold')
149
- }
100
+ this.element.appendChild(this.icon)
150
101
  }
151
102
 
152
103
  set (prop, value) {
@@ -156,9 +107,8 @@ class Button extends EventEmitter{
156
107
  this.element.value = value
157
108
  break
158
109
  case 'label':
159
- if (this.label) {
160
- this.label.innerHTML = value
161
- }
110
+ if (!this.label) this.buildLabel()
111
+ this.label.innerHTML = value
162
112
  break
163
113
  case 'text':
164
114
  this.element.innerHTML = value
@@ -168,6 +118,12 @@ class Button extends EventEmitter{
168
118
  this.icon.innerHTML = value
169
119
  }
170
120
  break
121
+ case 'enable':
122
+ this.element.disabled = false
123
+ break
124
+ case 'disable':
125
+ this.element.disabled = true
126
+ break
171
127
  default:
172
128
  // console.log('prop', prop)
173
129
  this.element.innerHTML = prop
@@ -177,12 +133,12 @@ class Button extends EventEmitter{
177
133
  }
178
134
 
179
135
  setLabel (value) {
180
- // console.log('setLabel', value)
181
- this.label.innerHTML = value
136
+ if (this.label) {
137
+ this.label.innerHTML = value
138
+ }
182
139
  }
183
140
 
184
141
  setText (value) {
185
- // console.log('setText', value)
186
142
  if (this.label) {
187
143
  this.setLabel(value)
188
144
  } else {
@@ -190,18 +146,12 @@ class Button extends EventEmitter{
190
146
  }
191
147
  }
192
148
 
193
- /**
194
- * Setter
195
- * @param {string} prop
196
- * @param {string} value
197
- * @return {Object} The class instance
198
- */
199
- get (prop, value) {
149
+ get (prop) {
200
150
  switch (prop) {
201
151
  case 'value':
202
152
  return this.element.value
203
153
  case 'label':
204
- return this.label.innerHTML
154
+ return this.label?.innerHTML ?? this.element.value
205
155
  default:
206
156
  return this.element.value
207
157
  }