material 0.7.1 → 0.7.4

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 (155) hide show
  1. package/LICENSE +9 -18
  2. package/README.md +1 -5
  3. package/index.js +25 -48
  4. package/package.json +3 -24
  5. package/src/badge.js +1 -1
  6. package/src/button.js +50 -100
  7. package/src/calendar.js +53 -53
  8. package/src/card.js +1 -1
  9. package/src/checkbox.js +52 -104
  10. package/src/datehour.js +7 -7
  11. package/src/dialog.js +5 -5
  12. package/src/divider.js +1 -1
  13. package/src/drawer.js +1 -17
  14. package/src/element/attribute.js +7 -10
  15. package/src/element/build.js +6 -7
  16. package/src/element/create.js +3 -6
  17. package/src/element/event.js +2 -2
  18. package/src/element/insert.js +9 -20
  19. package/src/element/observer.js +22 -0
  20. package/src/element/offset.js +2 -2
  21. package/src/element/style.js +12 -12
  22. package/src/element.js +2 -2
  23. package/src/file.js +1 -1
  24. package/src/form/build.js +7 -7
  25. package/src/form/controller.js +8 -8
  26. package/src/form/create.js +1 -1
  27. package/src/form/data.js +9 -9
  28. package/src/form/delete.js +1 -1
  29. package/src/form/render.js +9 -9
  30. package/src/form/set.js +1 -1
  31. package/src/form/submit.js +6 -6
  32. package/src/form/update.js +3 -3
  33. package/src/form/verify.js +4 -4
  34. package/src/form.js +9 -9
  35. package/src/icon.js +4 -4
  36. package/src/image.js +7 -7
  37. package/src/item.js +1 -1
  38. package/src/layout.js +14 -14
  39. package/src/link.js +1 -1
  40. package/src/list/build.js +8 -8
  41. package/src/list/click.js +3 -3
  42. package/src/list/filter.js +11 -11
  43. package/src/list/image.js +3 -3
  44. package/src/list/render.js +15 -15
  45. package/src/list/request.js +7 -7
  46. package/src/list/search.js +9 -9
  47. package/src/list/select.js +18 -18
  48. package/src/list/status.js +1 -1
  49. package/src/list/update.js +6 -6
  50. package/src/list/virtual.js +20 -20
  51. package/src/list/virtual.new.js +5 -5
  52. package/src/list.js +8 -10
  53. package/src/map/build.js +2 -2
  54. package/src/map/countries.js +8 -8
  55. package/src/map/display.js +13 -13
  56. package/src/map/focus.js +7 -7
  57. package/src/map/select.js +2 -2
  58. package/src/map/set.js +3 -3
  59. package/src/map/viewport.js +11 -11
  60. package/src/menu.js +12 -12
  61. package/src/mixin/control.js +3 -3
  62. package/src/mixin/controller.js +5 -5
  63. package/src/mixin/create.js +1 -1
  64. package/src/mixin/display.js +1 -1
  65. package/src/mixin/events.js +4 -16
  66. package/src/mixin/focus.js +1 -1
  67. package/src/mixin/icon.js +2 -2
  68. package/src/mixin/init.js +2 -2
  69. package/src/mixin/insert.js +5 -5
  70. package/src/mixin/label.js +2 -2
  71. package/src/mixin/settings.js +5 -5
  72. package/src/module/attach.js +35 -49
  73. package/src/module/attributes.js +2 -2
  74. package/src/module/build.js +6 -11
  75. package/src/module/classify.js +4 -4
  76. package/src/module/controller.js +5 -32
  77. package/src/module/css.js +12 -84
  78. package/src/module/dataset.js +1 -1
  79. package/src/module/dom.js +9 -3
  80. package/src/module/dot.js +4 -4
  81. package/src/module/emitter.js +1 -1
  82. package/src/module/event.js +2 -2
  83. package/src/module/events.js +29 -35
  84. package/src/module/extract.js +10 -10
  85. package/src/module/last.js +18 -0
  86. package/src/module/mediator.js +1 -13
  87. package/src/module/object.js +4 -4
  88. package/src/module/observer.js +43 -16
  89. package/src/module/remove.js +10 -10
  90. package/src/module/request.js +33 -0
  91. package/src/module/ripple.js +19 -24
  92. package/src/module/scrollbar.js +10 -14
  93. package/src/module/smoothscroll.js +5 -9
  94. package/src/module/utils.js +14 -23
  95. package/src/module/viewport.js +5 -5
  96. package/src/navigation.js +7 -1
  97. package/src/progress.js +1 -9
  98. package/src/search.js +24 -29
  99. package/src/select.js +6 -6
  100. package/src/selecter.js +39 -39
  101. package/src/selector.js +3 -3
  102. package/src/skin/material/button/action.sass +6 -6
  103. package/src/skin/material/button/button.sass +6 -6
  104. package/src/skin/material/button/file.sass +1 -1
  105. package/src/skin/material/button/floating.sass +5 -5
  106. package/src/skin/material/button/raised.sass +5 -5
  107. package/src/skin/material/button/stroked.sass +5 -5
  108. package/src/skin/material/component/navigation.sass +13 -1
  109. package/src/skin/material/control/checkbox.sass +21 -21
  110. package/src/skin/material/module/ripple.sass +1 -1
  111. package/src/slider.js +1 -1
  112. package/src/snackbar.js +12 -9
  113. package/src/styles/M3/abstracts/variables.sass +44 -0
  114. package/src/styles/M3/components/button.sass +26 -0
  115. package/src/styles/M3/modules/ripple.sass +9 -0
  116. package/src/styles/M3/themes/classic.sass +2 -0
  117. package/src/switch.js +1 -1
  118. package/src/switcher.js +15 -15
  119. package/src/tabs.js +6 -8
  120. package/src/tabview.js +26 -46
  121. package/src/text.js +1 -1
  122. package/src/textfield.js +1 -1
  123. package/src/toolbar.js +12 -12
  124. package/src/tooltip.js +7 -7
  125. package/src/tree.js +10 -66
  126. package/src/view/build.js +2 -2
  127. package/src/view/dataset.js +1 -1
  128. package/src/view.js +9 -74
  129. package/dist/demo-bundle.js +0 -2
  130. package/dist/demo-bundle.js.map +0 -1
  131. package/dist/demo.css +0 -93
  132. package/dist/demo.css.map +0 -7
  133. package/dist/demo.html +0 -24
  134. package/dist/demo.js +0 -159
  135. package/dist/icon/accessibility.svg +0 -5
  136. package/dist/icon/apps.svg +0 -5
  137. package/dist/icon/happy.svg +0 -6
  138. package/dist/icon/link.svg +0 -5
  139. package/dist/icon/more.svg +0 -5
  140. package/dist/icon/navi.svg +0 -5
  141. package/dist/icon/phone.svg +0 -6
  142. package/dist/icon/share.svg +0 -6
  143. package/dist/icon/side.svg +0 -5
  144. package/dist/icon/star.svg +0 -7
  145. package/dist/icon/star_border.svg +0 -6
  146. package/dist/material.css +0 -2429
  147. package/dist/material.css.map +0 -7
  148. package/dist/styles/demo.sass +0 -110
  149. package/dist/styles.css +0 -23
  150. package/rollup.config.js +0 -34
  151. package/src/container.js +0 -66
  152. package/src/element/ripple.js +0 -90
  153. package/src/field/email.js +0 -59
  154. package/src/field/image.js +0 -93
  155. package/src/module/addclass.js +0 -16
package/LICENSE CHANGED
@@ -1,20 +1,11 @@
1
- The MIT License (MIT)
1
+ This program is free software: you can redistribute it and/or modify
2
+ it under the terms of the GNU General Public License as published by
3
+ the Free Software Foundation, under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
2
4
 
3
- Copyright (c) 2019 2nd Floor
5
+ This program is distributed in the hope that it will be useful,
6
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
7
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8
+ GNU General Public License for more details.
4
9
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+ You should have received a copy of the GNU General Public License
11
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
package/README.md CHANGED
@@ -1,5 +1 @@
1
- Material JS is a set of user interface components for the web.
2
-
3
-
4
- [![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)
5
- =======
1
+ Material JS is a set of user interface ES6 components for the web.
package/index.js CHANGED
@@ -1,32 +1,39 @@
1
1
  import AppBar from './src/appbar'
2
+ import Badge from './src/badge'
2
3
  import Button from './src/button'
3
4
  import Card from './src/card'
5
+ import Checkbox from './src/checkbox'
4
6
  import Component from './src/component'
5
- import DateHour from './src/control/datehour'
7
+ import DateHour from './src/datehour'
6
8
  import Dialog from './src/dialog'
7
- import File from './src/control/file'
8
- import Loading from './src/control/loading'
9
- import Menu from './src/control/menu'
10
- import Select from './src/select'
11
- import Selecter from './src/control/selecter'
12
- import Snackbar from './src/snackbar'
13
- import Switch from './src/switch'
14
- import Switcher from './src/control/switcher'
15
- import Text from './src/text'
16
- import Textfield from './src/textfield'
9
+ import Drawer from './src/drawer'
17
10
  import Element from './src/element'
11
+ import File from './src/file'
12
+ import Form from './src/form'
13
+ import Image from './src/image'
18
14
  import Layout from './src/layout'
19
15
  import List from './src/list'
20
- import Tabview from './src/tabview'
16
+ import Loading from './src/loading'
17
+ import Menu from './src/menu'
18
+ import Navigation from './src/navigation'
19
+ import Progress from './src/progress'
20
+ import Select from './src/select'
21
+ import Selecter from './src/selecter'
22
+ import Snackbar from './src/snackbar'
23
+ import Slider from './src/slider'
24
+ import Switch from './src/switch'
25
+ import Switcher from './src/switcher'
26
+ import Tabs from './src/tabs'
21
27
  import TabView from './src/tabview'
22
28
  import Text from './src/text'
29
+ import Textfield from './src/textfield'
23
30
  import Toolbar from './src/toolbar'
24
31
  import Tooltip from './src/tooltip'
25
32
  import attach from './src/module/attach'
26
33
  import attributes from './src/module/attributes'
27
34
  import build from './src/module/build'
28
35
  import dataset from './src/module/dataset'
29
- import display from './src/module/display'
36
+ import display from './src/mixin/display'
30
37
  import events from './src/module/attach'
31
38
  import emitter from './src/module/emitter'
32
39
  import jsonToHTML from './src/module/jsontohtml'
@@ -35,39 +42,9 @@ import observer from './src/module/observer'
35
42
  import smoothscroll from './src/module/smoothscroll'
36
43
 
37
44
  export {
38
- AppBar
39
- Button,
40
- DateHour,
41
- Datehour,
42
- Dialog,
43
- Card,
44
- Component,
45
- Element,
46
- File,
47
- Loading,
48
- Menu,
49
- Select,
50
- Selecter,
51
- Snackbar,
52
- Switch,
53
- Switcher,
54
- Tabview,
55
- TabView,
56
- Text,
57
- Textfield,
58
- Toolbar,
59
- Tooltip,
60
- Layout,
61
- List,
62
- attach,
63
- attributes,
64
- build,
65
- dataset,
66
- display,
67
- events,
68
- emitter,
69
- jsonToHTML,
70
- mediator,
71
- observer,
72
- smoothscroll
45
+ AppBar, Button, Card, Checkbox, Component, DateHour, Dialog, Drawer, Element,
46
+ File, Form, Image, Layout, List, Loading, Menu, Navigation, Progress, Select,
47
+ Selecter, Slider, Snackbar, Switch, Switcher, Tabs, TabView, Text, Textfield, Toolbar, Tooltip,
48
+ attach, attributes, build, dataset, display, events, emitter, jsonToHTML, mediator,
49
+ observer, smoothscroll
73
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "A lightweight implementation of Material Design Components - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "url": "git+ssh://git@gitlab.com/alkaloid/material.git"
10
10
  },
11
11
  "author": "Jérôme Vial <jerome.vial@gmail.com>",
12
- "license": "MIT",
12
+ "license": "GPL-3",
13
13
  "bugs": {
14
14
  "url": "https://gitlab.com/alkaloid/material/issues"
15
15
  },
@@ -18,30 +18,9 @@
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
+ "standard": "^10.0.3"
35
22
  },
36
23
  "scripts": {
37
- "dev": "rollup -c --watch",
38
- "reload": "livereload 'dist/' -d",
39
- "styles": "sass --watch dist/styles/demo.sass:dist/demo.css",
40
- "watch": "npm-run-all --parallel reload dev",
41
- "docs": "jsdoc src -r -d docs",
42
24
  "test": "echo \"Error: no test specified\" && exit 1"
43
- },
44
- "dependencies": {
45
- "fs-extra": "^11.1.1"
46
25
  }
47
26
  }
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
  }