material 0.7.7 → 0.7.9
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/badge.js +22 -5
- package/src/form/build.js +2 -0
- package/src/list/select.js +2 -2
- package/src/mixin/display.js +13 -0
- package/src/snackbar.js +14 -8
- package/src/styles/M3/components/badge.sass +19 -0
package/package.json
CHANGED
package/src/badge.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import build from './module/build'
|
|
2
|
+
import display from './mixin/display'
|
|
3
|
+
|
|
4
|
+
const isStringNumber = (str) => !isNaN(parseFloat(str)) && isFinite(str)
|
|
2
5
|
|
|
3
6
|
class Badge {
|
|
4
7
|
static defaults = {
|
|
@@ -12,15 +15,29 @@ class Badge {
|
|
|
12
15
|
|
|
13
16
|
init (options) {
|
|
14
17
|
this.options = Object.assign({}, Badge.defaults, options || {})
|
|
15
|
-
Object.assign(this, build)
|
|
18
|
+
Object.assign(this, build, display)
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
set (text) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
this.element.innerHTML = text || ''
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get () {
|
|
26
|
+
return this.element.innerHTML
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inc (value) {
|
|
30
|
+
// console.log('inc', value)
|
|
31
|
+
let actual = this.element.innerHTML
|
|
32
|
+
|
|
33
|
+
if (actual === '') actual = '0'
|
|
34
|
+
|
|
35
|
+
if (isStringNumber(value) && isStringNumber(actual)) {
|
|
36
|
+
actual = (parseInt(value, 10) + parseInt(actual, 10)).toString()
|
|
23
37
|
}
|
|
38
|
+
|
|
39
|
+
this.element.innerHTML = actual
|
|
40
|
+
this.show()
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
|
package/src/form/build.js
CHANGED
package/src/list/select.js
CHANGED
|
@@ -42,11 +42,11 @@ export default {
|
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
getInfoById (id) {
|
|
45
|
-
return this.dataStore[id]
|
|
45
|
+
return JSON.parse(JSON.stringify(this.dataStore[id]))
|
|
46
46
|
},
|
|
47
47
|
|
|
48
48
|
getSelectedInfo () {
|
|
49
|
-
return this.dataStore[this.id]
|
|
49
|
+
return JSON.parse(JSON.stringify(this.dataStore[this.id]))
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
getItemById (id, silent) {
|
package/src/mixin/display.js
CHANGED
|
@@ -12,6 +12,10 @@ export default {
|
|
|
12
12
|
// console.log('show', this.visible)
|
|
13
13
|
if (!this.element) return
|
|
14
14
|
|
|
15
|
+
if (this.options.display !== false) {
|
|
16
|
+
this.element.style.display = ''
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
this.element.getBoundingClientRect()
|
|
16
20
|
|
|
17
21
|
this.element.classList.add('show')
|
|
@@ -26,6 +30,7 @@ export default {
|
|
|
26
30
|
},
|
|
27
31
|
|
|
28
32
|
hide () {
|
|
33
|
+
// console.log('hide', this.element)
|
|
29
34
|
if (!this.element) return
|
|
30
35
|
|
|
31
36
|
this.element.classList.remove('show')
|
|
@@ -35,6 +40,14 @@ export default {
|
|
|
35
40
|
this.underlay.classList.remove('show')
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
if (this.options.transition && this.element) {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
if (this.options.display !== false) {
|
|
46
|
+
this.element.style.display = 'none'
|
|
47
|
+
}
|
|
48
|
+
}, this.options.transition)
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
this.emit?.('hide')
|
|
39
52
|
return this
|
|
40
53
|
},
|
package/src/snackbar.js
CHANGED
|
@@ -5,6 +5,7 @@ import build from './module/build'
|
|
|
5
5
|
import bindEvents from './module/events'
|
|
6
6
|
import display from './mixin/display'
|
|
7
7
|
// ui element
|
|
8
|
+
import Element from './element'
|
|
8
9
|
import Text from './text'
|
|
9
10
|
import Button from './button'
|
|
10
11
|
|
|
@@ -17,10 +18,13 @@ class Snackbar extends EventEmitter {
|
|
|
17
18
|
close: false,
|
|
18
19
|
layout: [
|
|
19
20
|
[Text, 'message', { tag: 'span', class: 'message' }],
|
|
20
|
-
[
|
|
21
|
+
[Element, 'action', { tag: 'span', class: 'action' },
|
|
22
|
+
[Button, 'callback', { class: 'callback', type: 'link' }],
|
|
23
|
+
[Button, 'close', { class: 'close', type: 'action' }]
|
|
24
|
+
]
|
|
21
25
|
],
|
|
22
26
|
events: [
|
|
23
|
-
['ui.
|
|
27
|
+
['ui.callback.click', 'action'],
|
|
24
28
|
['ui.close.click', 'destroy']
|
|
25
29
|
]
|
|
26
30
|
}
|
|
@@ -69,12 +73,14 @@ class Snackbar extends EventEmitter {
|
|
|
69
73
|
this.ui.message.set(this.options.message)
|
|
70
74
|
|
|
71
75
|
if (this.options.action) {
|
|
72
|
-
this.ui.
|
|
73
|
-
this.ui.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
this.ui.callback.set(this.options.action)
|
|
77
|
+
this.ui.callback.element.classList.add('show')
|
|
78
|
+
this.ui.action.classList.add('show')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.options.close) {
|
|
82
|
+
this.ui.close.element.classList.add('show')
|
|
83
|
+
this.ui.action.classList.add('show')
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.badge
|
|
2
|
+
opacity: .9
|
|
3
|
+
font-family: helvetica, arial, sans-serif
|
|
4
|
+
line-height: 1.5em
|
|
5
|
+
display: none
|
|
6
|
+
cursor: pointer
|
|
7
|
+
font-size: .7em
|
|
8
|
+
font-weight: 500
|
|
9
|
+
text-align: center
|
|
10
|
+
position: absolute
|
|
11
|
+
z-index: 4
|
|
12
|
+
right: 0px
|
|
13
|
+
top: 1px
|
|
14
|
+
height: 16px
|
|
15
|
+
min-width: 16px
|
|
16
|
+
padding: 1px 5px
|
|
17
|
+
border-radius: 8px
|
|
18
|
+
// border: 1px solid rgba(255,255,255,1)
|
|
19
|
+
background-color: #BB1A1B
|