material 0.9.16 → 0.9.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.9.16",
3
+ "version": "0.9.18",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/element.js CHANGED
@@ -16,11 +16,16 @@ class Element {
16
16
 
17
17
  // Apply additional attributes
18
18
  for (const key in this.options) {
19
- if (!['tag', 'container', 'html', 'text', 'id'].includes(key)) {
19
+ if (!['tag', 'container', 'html', 'text', 'id', 'data'].includes(key)) {
20
20
  element.setAttribute(key, this.options[key])
21
21
  }
22
22
  }
23
23
 
24
+ // Apply additional dataset
25
+ for (const key in this.options.data) {
26
+ element.setAttribute('data-' + key, this.options.data[key])
27
+ }
28
+
24
29
  // Append to container if available
25
30
  if (this.options.container) {
26
31
  this.options.container.appendChild(element)
package/src/loader.js CHANGED
@@ -1,6 +1,9 @@
1
+ import emitter from './module/emitter'
2
+
1
3
  class Loader {
2
4
  static defaults = {
3
- class: 'loader'
5
+ class: 'loader',
6
+ timeout: 10000
4
7
  }
5
8
 
6
9
  constructor (options) {
@@ -10,6 +13,7 @@ class Loader {
10
13
 
11
14
  init (options) {
12
15
  this.options = { ...Loader.defaults, ...options }
16
+ Object.assign(this, emitter)
13
17
  }
14
18
 
15
19
  build () {
@@ -77,9 +81,19 @@ class Loader {
77
81
 
78
82
  show () {
79
83
  this.element.classList.add('show')
84
+
85
+ clearTimeout(this.timeout)
86
+
87
+ if (this.options.timeout) {
88
+ this.timeout = setTimeout(() => {
89
+ this.hide()
90
+ this.emit('timeout')
91
+ }, this.options.timeout)
92
+ }
80
93
  }
81
94
 
82
95
  hide () {
96
+ clearTimeout(this.timeout)
83
97
  this.element.classList.remove('show')
84
98
  }
85
99
  }