material 0.9.15 → 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 +1 -1
- package/src/dialog.js +3 -1
- package/src/element.js +6 -1
- package/src/loader.js +15 -1
- package/src/module/request.js +12 -2
package/package.json
CHANGED
package/src/dialog.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import emitter from './module/emitter'
|
|
3
3
|
import events from './module/events'
|
|
4
4
|
import display from './mixin/display'
|
|
5
|
+
import * as css from './module/css'
|
|
5
6
|
|
|
6
7
|
import Element from './element'
|
|
7
8
|
import Text from './text'
|
|
@@ -55,7 +56,8 @@ class Dialog {
|
|
|
55
56
|
this.element = this.element
|
|
56
57
|
|
|
57
58
|
if (this.options.class !== 'dialog') {
|
|
58
|
-
|
|
59
|
+
// console.log('css add', this.options.class)
|
|
60
|
+
css.add(this.element, this.options.class)
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
if (this.options.position) {
|
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
|
}
|
package/src/module/request.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
const request = async (
|
|
1
|
+
const request = async (
|
|
2
|
+
url,
|
|
3
|
+
method = 'GET',
|
|
4
|
+
body = null,
|
|
5
|
+
headers = {},
|
|
6
|
+
signal = null,
|
|
7
|
+
debug = false,
|
|
8
|
+
cache = 'no-store' // Adding cache parameter with a default value
|
|
9
|
+
) => {
|
|
10
|
+
// console.trace('request')
|
|
2
11
|
const defaultHeaders = {
|
|
3
12
|
Accept: 'application/json',
|
|
4
13
|
'Content-Type': 'application/json'
|
|
@@ -7,7 +16,8 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
|
|
|
7
16
|
const options = {
|
|
8
17
|
method,
|
|
9
18
|
headers: { ...defaultHeaders, ...headers },
|
|
10
|
-
signal
|
|
19
|
+
signal,
|
|
20
|
+
cache // Including the cache option in the request
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
if (debug) {
|