material 0.9.16 → 0.9.19

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.19",
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: 17000
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 () {
@@ -21,51 +25,69 @@ class Loader {
21
25
  this.element.appendChild(this.container)
22
26
 
23
27
  const svg = `
24
- <svg
25
- version="1.1"
26
- id="dc-spinner"
27
- xmlns="http://www.w3.org/2000/svg"
28
- x="0px" y="0px"
29
- width:"38"
30
- height:"38"
31
- viewBox="0 0 38 38"
32
- preserveAspectRatio="xMinYMin meet"
33
- >
34
- <path class="circles" d="M20,35c-8.271,0-15-6.729-15-15S11.729,5,20,5s15,6.729,15,15S28.271,35,20,35z M20,5.203
35
- C11.841,5.203,5.203,11.841,5.203,20c0,8.159,6.638,14.797,14.797,14.797S34.797,28.159,34.797,20
36
- C34.797,11.841,28.159,5.203,20,5.203z">
37
- </path>
38
-
39
- <path class="circles" d="M20,33.125c-7.237,0-13.125-5.888-13.125-13.125S12.763,6.875,20,6.875S33.125,12.763,33.125,20
40
- S27.237,33.125,20,33.125z M20,7.078C12.875,7.078,7.078,12.875,7.078,20c0,7.125,5.797,12.922,12.922,12.922
41
- S32.922,27.125,32.922,20C32.922,12.875,27.125,7.078,20,7.078z">
42
- </path>
28
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
29
+ <circle
30
+ class="base"
31
+ cx="25"
32
+ cy="25"
33
+ r="20"
34
+ fill="none"
35
+ stroke="#e5e7eb"
36
+ stroke-width="3"
37
+ />
38
+ <circle
39
+ class="base"
40
+ cx="25"
41
+ cy="25"
42
+ r="16"
43
+ fill="none"
44
+ stroke="#e5e7eb"
45
+ stroke-width="2"
46
+ />
47
+
48
+ <circle
49
+ class="outer"
50
+ cx="25"
51
+ cy="25"
52
+ r="20"
53
+ fill="none"
54
+ stroke-width="3"
55
+ stroke-linecap="round"
56
+ stroke-dasharray="62.8 62.8"
57
+ stroke-dashoffset="62.8">
58
+ <animateTransform
59
+ attributeName="transform"
60
+ type="rotate"
61
+ from="0 25 25"
62
+ to="360 25 25"
63
+ calcMode="spline"
64
+ keySplines="0.4, 0, 0.2, 1"
65
+ keyTimes="0;1"
66
+ dur="2s"
67
+ repeatCount="indefinite"
68
+ />
69
+ </circle>
43
70
 
44
- <path class="circletwo" stroke-width="0.6027" stroke-miterlimit="10" d="M5.203,20
45
- c0-8.159,6.638-14.797,14.797-14.797V5C11.729,5,5,11.729,5,20s6.729,15,15,15v-0.203C11.841,34.797,5.203,28.159,5.203,20z">
46
- <animateTransform
47
- attributeName="transform"
48
- type="rotate"
49
- from="0 20 20"
50
- to="360 20 20"
51
- calcMode="spline"
52
- keySplines="0.4, 0, 0.2, 1"
53
- keyTimes="0;1"
54
- dur="2s"
55
- repeatCount="indefinite" />
56
- </path>
71
+ <circle
72
+ class="inner"
73
+ cx="25"
74
+ cy="25"
75
+ r="16"
76
+ fill="none"
57
77
 
58
- <path class="circleone" stroke-width="0.2027" stroke-miterlimit="10" d="M7.078,20
59
- c0-7.125,5.797-12.922,12.922-12.922V6.875C12.763,6.875,6.875,12.763,6.875,20S12.763,33.125,20,33.125v-0.203
60
- C12.875,32.922,7.078,27.125,7.078,20z">
61
- <animateTransform
78
+ stroke-width="2"
79
+ stroke-linecap="round"
80
+ stroke-dasharray="50.24 50.24"
81
+ stroke-dashoffset="50.24">
82
+ <animateTransform
62
83
  attributeName="transform"
63
84
  type="rotate"
64
- from="0 20 20"
65
- to="360 20 20"
66
- dur="1.8s"
67
- repeatCount="indefinite" />
68
- </path>
85
+ from="0 25 25"
86
+ to="360 25 25"
87
+ dur="1.8s"
88
+ repeatCount="indefinite"
89
+ />
90
+ </circle>
69
91
  </svg>`
70
92
 
71
93
  this.container.innerHTML = svg
@@ -75,11 +97,25 @@ class Loader {
75
97
  this.container.appendChild(this.text)
76
98
  }
77
99
 
100
+ setText (text) {
101
+ this.text.innerHTML = text
102
+ }
103
+
78
104
  show () {
79
105
  this.element.classList.add('show')
106
+
107
+ clearTimeout(this.timeout)
108
+
109
+ if (this.options.timeout) {
110
+ this.timeout = setTimeout(() => {
111
+ this.hide()
112
+ this.emit('timeout')
113
+ }, this.options.timeout)
114
+ }
80
115
  }
81
116
 
82
117
  hide () {
118
+ clearTimeout(this.timeout)
83
119
  this.element.classList.remove('show')
84
120
  }
85
121
  }