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.
- package/LICENSE +9 -18
- package/README.md +1 -5
- package/index.js +25 -48
- package/package.json +3 -24
- package/src/badge.js +1 -1
- package/src/button.js +50 -100
- package/src/calendar.js +53 -53
- package/src/card.js +1 -1
- package/src/checkbox.js +52 -104
- package/src/datehour.js +7 -7
- package/src/dialog.js +5 -5
- package/src/divider.js +1 -1
- package/src/drawer.js +1 -17
- package/src/element/attribute.js +7 -10
- package/src/element/build.js +6 -7
- package/src/element/create.js +3 -6
- package/src/element/event.js +2 -2
- package/src/element/insert.js +9 -20
- package/src/element/observer.js +22 -0
- package/src/element/offset.js +2 -2
- package/src/element/style.js +12 -12
- package/src/element.js +2 -2
- package/src/file.js +1 -1
- package/src/form/build.js +7 -7
- package/src/form/controller.js +8 -8
- package/src/form/create.js +1 -1
- package/src/form/data.js +9 -9
- package/src/form/delete.js +1 -1
- package/src/form/render.js +9 -9
- package/src/form/set.js +1 -1
- package/src/form/submit.js +6 -6
- package/src/form/update.js +3 -3
- package/src/form/verify.js +4 -4
- package/src/form.js +9 -9
- package/src/icon.js +4 -4
- package/src/image.js +7 -7
- package/src/item.js +1 -1
- package/src/layout.js +14 -14
- package/src/link.js +1 -1
- package/src/list/build.js +8 -8
- package/src/list/click.js +3 -3
- package/src/list/filter.js +11 -11
- package/src/list/image.js +3 -3
- package/src/list/render.js +15 -15
- package/src/list/request.js +7 -7
- package/src/list/search.js +9 -9
- package/src/list/select.js +18 -18
- package/src/list/status.js +1 -1
- package/src/list/update.js +6 -6
- package/src/list/virtual.js +20 -20
- package/src/list/virtual.new.js +5 -5
- package/src/list.js +8 -10
- package/src/map/build.js +2 -2
- package/src/map/countries.js +8 -8
- package/src/map/display.js +13 -13
- package/src/map/focus.js +7 -7
- package/src/map/select.js +2 -2
- package/src/map/set.js +3 -3
- package/src/map/viewport.js +11 -11
- package/src/menu.js +12 -12
- package/src/mixin/control.js +3 -3
- package/src/mixin/controller.js +5 -5
- package/src/mixin/create.js +1 -1
- package/src/mixin/display.js +1 -1
- package/src/mixin/events.js +4 -16
- package/src/mixin/focus.js +1 -1
- package/src/mixin/icon.js +2 -2
- package/src/mixin/init.js +2 -2
- package/src/mixin/insert.js +5 -5
- package/src/mixin/label.js +2 -2
- package/src/mixin/settings.js +5 -5
- package/src/module/attach.js +35 -49
- package/src/module/attributes.js +2 -2
- package/src/module/build.js +6 -11
- package/src/module/classify.js +4 -4
- package/src/module/controller.js +5 -32
- package/src/module/css.js +12 -84
- package/src/module/dataset.js +1 -1
- package/src/module/dom.js +9 -3
- package/src/module/dot.js +4 -4
- package/src/module/emitter.js +1 -1
- package/src/module/event.js +2 -2
- package/src/module/events.js +29 -35
- package/src/module/extract.js +10 -10
- package/src/module/last.js +18 -0
- package/src/module/mediator.js +1 -13
- package/src/module/object.js +4 -4
- package/src/module/observer.js +43 -16
- package/src/module/remove.js +10 -10
- package/src/module/request.js +33 -0
- package/src/module/ripple.js +19 -24
- package/src/module/scrollbar.js +10 -14
- package/src/module/smoothscroll.js +5 -9
- package/src/module/utils.js +14 -23
- package/src/module/viewport.js +5 -5
- package/src/navigation.js +7 -1
- package/src/progress.js +1 -9
- package/src/search.js +24 -29
- package/src/select.js +6 -6
- package/src/selecter.js +39 -39
- package/src/selector.js +3 -3
- package/src/skin/material/button/action.sass +6 -6
- package/src/skin/material/button/button.sass +6 -6
- package/src/skin/material/button/file.sass +1 -1
- package/src/skin/material/button/floating.sass +5 -5
- package/src/skin/material/button/raised.sass +5 -5
- package/src/skin/material/button/stroked.sass +5 -5
- package/src/skin/material/component/navigation.sass +13 -1
- package/src/skin/material/control/checkbox.sass +21 -21
- package/src/skin/material/module/ripple.sass +1 -1
- package/src/slider.js +1 -1
- package/src/snackbar.js +12 -9
- package/src/styles/M3/abstracts/variables.sass +44 -0
- package/src/styles/M3/components/button.sass +26 -0
- package/src/styles/M3/modules/ripple.sass +9 -0
- package/src/styles/M3/themes/classic.sass +2 -0
- package/src/switch.js +1 -1
- package/src/switcher.js +15 -15
- package/src/tabs.js +6 -8
- package/src/tabview.js +26 -46
- package/src/text.js +1 -1
- package/src/textfield.js +1 -1
- package/src/toolbar.js +12 -12
- package/src/tooltip.js +7 -7
- package/src/tree.js +10 -66
- package/src/view/build.js +2 -2
- package/src/view/dataset.js +1 -1
- package/src/view.js +9 -74
- package/dist/demo-bundle.js +0 -2
- package/dist/demo-bundle.js.map +0 -1
- package/dist/demo.css +0 -93
- package/dist/demo.css.map +0 -7
- package/dist/demo.html +0 -24
- package/dist/demo.js +0 -159
- package/dist/icon/accessibility.svg +0 -5
- package/dist/icon/apps.svg +0 -5
- package/dist/icon/happy.svg +0 -6
- package/dist/icon/link.svg +0 -5
- package/dist/icon/more.svg +0 -5
- package/dist/icon/navi.svg +0 -5
- package/dist/icon/phone.svg +0 -6
- package/dist/icon/share.svg +0 -6
- package/dist/icon/side.svg +0 -5
- package/dist/icon/star.svg +0 -7
- package/dist/icon/star_border.svg +0 -6
- package/dist/material.css +0 -2429
- package/dist/material.css.map +0 -7
- package/dist/styles/demo.sass +0 -110
- package/dist/styles.css +0 -23
- package/rollup.config.js +0 -34
- package/src/container.js +0 -66
- package/src/element/ripple.js +0 -90
- package/src/field/email.js +0 -59
- package/src/field/image.js +0 -93
- package/src/module/addclass.js +0 -16
package/src/layout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is as isObject } from './module/object'
|
|
2
|
-
import css from './module/css'
|
|
2
|
+
import * as css from './module/css'
|
|
3
3
|
|
|
4
4
|
class Layout {
|
|
5
5
|
constructor (schema, container) {
|
|
@@ -16,10 +16,10 @@ class Layout {
|
|
|
16
16
|
structure = structure || {}
|
|
17
17
|
let component = null
|
|
18
18
|
|
|
19
|
-
for (
|
|
19
|
+
for (let i = 0; i < schema.length; i++) {
|
|
20
20
|
// console.log('index', i, typeof schema[i])
|
|
21
21
|
var name
|
|
22
|
-
|
|
22
|
+
let options = {}
|
|
23
23
|
|
|
24
24
|
if (schema[i] instanceof Object &&
|
|
25
25
|
typeof schema[i] === 'function') {
|
|
@@ -37,7 +37,7 @@ class Layout {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
component = new schema[i](options)
|
|
40
|
-
|
|
40
|
+
const element = component.element || component
|
|
41
41
|
|
|
42
42
|
if (level === 1) {
|
|
43
43
|
structure.element = element
|
|
@@ -49,7 +49,7 @@ class Layout {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// if (component) {
|
|
52
|
-
// this.display(component.
|
|
52
|
+
// this.display(component.element, options)
|
|
53
53
|
// this.style(component, options)
|
|
54
54
|
// }
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ class Layout {
|
|
|
57
57
|
if (component.insert) {
|
|
58
58
|
component.insert(container)
|
|
59
59
|
} else {
|
|
60
|
-
|
|
60
|
+
const wrapper = container.element || container
|
|
61
61
|
|
|
62
62
|
wrapper.appendChild(element)
|
|
63
63
|
|
|
@@ -68,7 +68,7 @@ class Layout {
|
|
|
68
68
|
component._container = container
|
|
69
69
|
}
|
|
70
70
|
} else if (Array.isArray(schema[i])) {
|
|
71
|
-
|
|
71
|
+
// console.log('------', schema[i])
|
|
72
72
|
if (component == null) {
|
|
73
73
|
component = container
|
|
74
74
|
}
|
|
@@ -80,8 +80,8 @@ class Layout {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
display (element, options) {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
const display = options.display
|
|
84
|
+
const direction = options.direction || 'horizontal'
|
|
85
85
|
|
|
86
86
|
if (!element || !display) return
|
|
87
87
|
|
|
@@ -93,14 +93,14 @@ class Layout {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
style (component) {
|
|
96
|
-
|
|
96
|
+
const options = component.options || {}
|
|
97
97
|
|
|
98
98
|
// console.log('component', component);
|
|
99
99
|
|
|
100
100
|
if (options.flex) {
|
|
101
101
|
css.add(component.element, 'flex-' + options.flex)
|
|
102
102
|
} else {
|
|
103
|
-
|
|
103
|
+
const size = options.size
|
|
104
104
|
if (options.size && options.width) {
|
|
105
105
|
component.element.width = size + 'px'
|
|
106
106
|
} else if (options.size && options.height) {
|
|
@@ -128,11 +128,11 @@ class Layout {
|
|
|
128
128
|
extractInfo (object) {
|
|
129
129
|
// console.log('extractField', object)
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
const field = {}
|
|
132
132
|
|
|
133
|
-
for (
|
|
133
|
+
for (const property in object) {
|
|
134
134
|
if (object.hasOwnProperty(property)) {
|
|
135
|
-
|
|
135
|
+
const infos = property.split(/\./)
|
|
136
136
|
|
|
137
137
|
if (infos[0] === 'info' && infos[1] !== undefined) {
|
|
138
138
|
// console.log('field', infos[0], infos[1])
|
package/src/link.js
CHANGED
package/src/list/build.js
CHANGED
|
@@ -40,12 +40,12 @@ export default {
|
|
|
40
40
|
this.options.container.appendChild(this.element)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const scrollbarOffset = scrollbar()
|
|
44
44
|
|
|
45
45
|
// console.log('scrollbarOffset', scrollbarOffset)
|
|
46
46
|
if (this.ui && this.ui.body) {
|
|
47
47
|
// console.log('body padding', 11 - scrollbarOffset + 'px')
|
|
48
|
-
this.ui.body.style
|
|
48
|
+
this.ui.body.style.marginRight = 11 - scrollbarOffset + 'px'
|
|
49
49
|
this.ui.body.classList.add('offset' + scrollbarOffset)
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -53,16 +53,16 @@ export default {
|
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
addClass (c) {
|
|
56
|
-
|
|
56
|
+
const list = c.split(' ')
|
|
57
57
|
|
|
58
|
-
for (
|
|
58
|
+
for (let i = 0; i < list.length; i++) {
|
|
59
59
|
this.element.classList.add(list[i])
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
|
|
63
63
|
buildVirtual () {
|
|
64
64
|
// console.log('buildVirtual', this.options.class)
|
|
65
|
-
|
|
65
|
+
let height = 80
|
|
66
66
|
this.size = this.options.list.size
|
|
67
67
|
this.stop = false
|
|
68
68
|
|
|
@@ -100,15 +100,15 @@ export default {
|
|
|
100
100
|
// console.log('progress', progress, this.count)
|
|
101
101
|
|
|
102
102
|
if (this.statusDisplay) {
|
|
103
|
-
|
|
103
|
+
const percent = parseInt(progress / this.count * 100)
|
|
104
104
|
this.statusDisplay('count', percent + '% | ' + progress + ' / ' + this.count)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
this.onProgress(progress)
|
|
108
108
|
})
|
|
109
109
|
// .on('size', (size) => {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
// console.log('!!!!size', size)
|
|
111
|
+
// this.size = size
|
|
112
112
|
// })
|
|
113
113
|
//
|
|
114
114
|
},
|
package/src/list/click.js
CHANGED
package/src/list/filter.js
CHANGED
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
initFilter () {
|
|
4
4
|
this.filter = this.extractFilter(this.ui)
|
|
5
5
|
|
|
6
|
-
for (
|
|
6
|
+
for (const name in this.filter) {
|
|
7
7
|
if (this.filter.hasOwnProperty(name)) {
|
|
8
8
|
this.filter[name].on('change', () => {
|
|
9
9
|
this.request()
|
|
@@ -15,15 +15,15 @@ export default {
|
|
|
15
15
|
this.clearFilter()
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
this.ui
|
|
18
|
+
this.ui.filter.on('click', () => {
|
|
19
19
|
this.toggleFilter()
|
|
20
20
|
})
|
|
21
21
|
},
|
|
22
22
|
|
|
23
23
|
getFilter () {
|
|
24
24
|
console.log('getFilter')
|
|
25
|
-
|
|
26
|
-
for (
|
|
25
|
+
let filter = null
|
|
26
|
+
for (const name in this.filter) {
|
|
27
27
|
if (this.filter.hasOwnProperty(name)) {
|
|
28
28
|
console.log('--', typeof this.filter[name].get(), this.filter[name].get())
|
|
29
29
|
if (this.filter[name].get() !== ''/* && this.filter[name].get() !== [] */) {
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// console.log('showSearch')
|
|
64
|
-
this.ui
|
|
64
|
+
this.ui.filter.element.classList.add('selected')
|
|
65
65
|
this.ui['filter-input'].classList.add('show')
|
|
66
66
|
|
|
67
67
|
// this.ui['search-list'].classList.add('show')
|
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
*/
|
|
75
75
|
hideFilter () {
|
|
76
76
|
// console.log('hideSearch')
|
|
77
|
-
this.ui
|
|
77
|
+
this.ui.filter.element.classList.remove('selected')
|
|
78
78
|
this.ui['filter-input'].classList.remove('show')
|
|
79
79
|
// this.ui['search-list'].classList.remove('show')
|
|
80
80
|
// this.ui.body.classList.remove('hide')
|
|
@@ -83,7 +83,7 @@ export default {
|
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
clearFilter () {
|
|
86
|
-
for (
|
|
86
|
+
for (const name in this.filter) {
|
|
87
87
|
if (this.filter.hasOwnProperty(name)) {
|
|
88
88
|
this.filter[name].set('')
|
|
89
89
|
}
|
|
@@ -95,14 +95,14 @@ export default {
|
|
|
95
95
|
extractFilter (object) {
|
|
96
96
|
// console.log('extractField', object)
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const filter = {}
|
|
99
99
|
|
|
100
|
-
for (
|
|
100
|
+
for (const property in object) {
|
|
101
101
|
if (object.hasOwnProperty(property)) {
|
|
102
|
-
|
|
102
|
+
const str = property.split(/\./)
|
|
103
103
|
|
|
104
104
|
if (str[0] === 'filter' && str[1] !== undefined) {
|
|
105
|
-
|
|
105
|
+
const name = property.substr(7, property.length)
|
|
106
106
|
|
|
107
107
|
filter[name] = object[property]
|
|
108
108
|
}
|
package/src/list/image.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
image (info, layout) {
|
|
3
3
|
if (info.image) {
|
|
4
|
-
|
|
4
|
+
let format = 'thumb'
|
|
5
5
|
if (this.options.image && this.options.image.format) {
|
|
6
6
|
format = this.options.image.format || format + '/'
|
|
7
7
|
} else {
|
|
8
8
|
format = ''
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const r = Math.floor(Math.random() * 100000) + 1
|
|
12
12
|
|
|
13
13
|
if (info.image.filename) {
|
|
14
|
-
|
|
14
|
+
const image = info.image.url + format + info.image.filename
|
|
15
15
|
layout.get('image').style.backgroundImage = 'url("' + image + '?' + r + '")'
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/list/render.js
CHANGED
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
// console.log('renderItem', info)
|
|
24
24
|
info = info || {}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const container = this.ui.body
|
|
27
27
|
|
|
28
28
|
if (context === 'create') {
|
|
29
29
|
container.scrolltop = 0
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
// container = this.ui['search-list']
|
|
34
34
|
// }
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const element = new Element({
|
|
37
37
|
tag: 'li',
|
|
38
38
|
class: 'item'
|
|
39
39
|
})
|
|
@@ -47,10 +47,10 @@ export default {
|
|
|
47
47
|
element.dataset.id = info[this.dataId]
|
|
48
48
|
element.dataset.info = this.options.info
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
let layout = null
|
|
51
51
|
|
|
52
52
|
if (this.options.itemSwitch) {
|
|
53
|
-
|
|
53
|
+
const item = info[this.options.itemSwitch]
|
|
54
54
|
|
|
55
55
|
if (this.options.layout.item[item]) {
|
|
56
56
|
layout = new Layout(this.options.layout.item[item], element)
|
|
@@ -58,7 +58,7 @@ export default {
|
|
|
58
58
|
layout = new Layout(this.options.layout.item.base, element)
|
|
59
59
|
}
|
|
60
60
|
} else {
|
|
61
|
-
|
|
61
|
+
const itemName = this.options.itemName || 'item'
|
|
62
62
|
layout = new Layout(this.options.layout[itemName], element)
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -91,11 +91,11 @@ export default {
|
|
|
91
91
|
*/
|
|
92
92
|
renderInfo (layout, object) {
|
|
93
93
|
// console.log('renderInfo', object)
|
|
94
|
-
|
|
94
|
+
const info = dot(object)
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
const f = this.extractInfo(layout.component)
|
|
97
97
|
|
|
98
|
-
for (
|
|
98
|
+
for (const field in f) {
|
|
99
99
|
if (f.hasOwnProperty(field)) {
|
|
100
100
|
if (f[field] && f[field].set) {
|
|
101
101
|
f[field].set(this.objectValueByDotKey(object, field))
|
|
@@ -108,11 +108,11 @@ export default {
|
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
objectValueByDotKey (object, dotkey) {
|
|
111
|
-
|
|
111
|
+
const keys = dotkey.split(/\./)
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
let value = Object.assign({}, object)
|
|
114
114
|
|
|
115
|
-
for (
|
|
115
|
+
for (let i = 0; i < keys.length; i++) {
|
|
116
116
|
if (value !== undefined) {
|
|
117
117
|
value = value[keys[i]]
|
|
118
118
|
}
|
|
@@ -124,14 +124,14 @@ export default {
|
|
|
124
124
|
extractInfo (object) {
|
|
125
125
|
// console.log('extractField', object)
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
const field = {}
|
|
128
128
|
|
|
129
|
-
for (
|
|
129
|
+
for (const property in object) {
|
|
130
130
|
if (object.hasOwnProperty(property)) {
|
|
131
|
-
|
|
131
|
+
const infos = property.split(/\./)
|
|
132
132
|
|
|
133
133
|
if (infos[0] === 'info' && infos[1] !== undefined) {
|
|
134
|
-
|
|
134
|
+
const name = property.substr(5, property.length)
|
|
135
135
|
// console.log('field', name, property)
|
|
136
136
|
|
|
137
137
|
field[name] = object[property]
|
package/src/list/request.js
CHANGED
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
this.data = this.data || []
|
|
19
|
-
|
|
19
|
+
let signal = null
|
|
20
20
|
|
|
21
21
|
if (this.abortController) {
|
|
22
22
|
// console.log('abort')
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
this.ui.body.scrolltop = 0
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const route = this.buildRoute(page, size)
|
|
41
41
|
|
|
42
42
|
if (more !== true && this.options.count) {
|
|
43
43
|
this.requestCount(route)
|
|
@@ -45,7 +45,7 @@ export default {
|
|
|
45
45
|
|
|
46
46
|
// console.log('route - ', this.rand, route)
|
|
47
47
|
|
|
48
|
-
fetch(route, {signal}).then((resp) => {
|
|
48
|
+
fetch(route, { signal }).then((resp) => {
|
|
49
49
|
return resp.json()
|
|
50
50
|
}).then((data) => {
|
|
51
51
|
if (this.options.debug) {
|
|
@@ -68,7 +68,7 @@ export default {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (more === true) {
|
|
71
|
-
|
|
71
|
+
const a = this.data.concat(data)
|
|
72
72
|
this.data = a
|
|
73
73
|
this.storeData(data, more)
|
|
74
74
|
this.virtual.add(this.data)
|
|
@@ -95,7 +95,7 @@ export default {
|
|
|
95
95
|
|
|
96
96
|
requestCount (route, signal) {
|
|
97
97
|
// console.log('fetchCount', route)
|
|
98
|
-
fetch(route + '&count=1', {signal}).then((resp) => {
|
|
98
|
+
fetch(route + '&count=1', { signal }).then((resp) => {
|
|
99
99
|
return resp.json()
|
|
100
100
|
}).then((data) => {
|
|
101
101
|
// console.log('data', data.count)
|
|
@@ -137,7 +137,7 @@ export default {
|
|
|
137
137
|
page = page || 1
|
|
138
138
|
size = size || this.options.list.size
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
let route = this.options.route
|
|
141
141
|
|
|
142
142
|
if (path) {
|
|
143
143
|
route = this.options.route[path]
|
|
@@ -174,7 +174,7 @@ export default {
|
|
|
174
174
|
// console.log('storeData', this.dataStore)
|
|
175
175
|
this.dataStore = this.dataStore || {}
|
|
176
176
|
|
|
177
|
-
for (
|
|
177
|
+
for (let i = 0; i < list.length; i++) {
|
|
178
178
|
this.dataList.push(list[i][this.dataId])
|
|
179
179
|
this.dataStore[list[i][this.dataId]] = list[i]
|
|
180
180
|
}
|
package/src/list/search.js
CHANGED
|
@@ -15,7 +15,7 @@ export default {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
this.data = this.data || []
|
|
18
|
-
|
|
18
|
+
let signal = null
|
|
19
19
|
|
|
20
20
|
if (this.abortController) {
|
|
21
21
|
this.abortController.abort()
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
this.ui.body.scrolltop = 0
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
let route = this.buildRoute(page, size, 'search')
|
|
38
38
|
|
|
39
39
|
route = this.addParams(route, 'search=' + keywords)
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
this.requestCount(route)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
fetch(route, {signal}).then((resp) => {
|
|
47
|
+
fetch(route, { signal }).then((resp) => {
|
|
48
48
|
return resp.json()
|
|
49
49
|
}).then((data) => {
|
|
50
50
|
// console.log('data', data)
|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (more === true) {
|
|
67
|
-
|
|
67
|
+
const a = this.data.concat(data)
|
|
68
68
|
this.data = a
|
|
69
69
|
this.storeData(data, more)
|
|
70
70
|
this.virtual.add(this.data)
|
|
@@ -118,9 +118,9 @@ export default {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (this.ui['search-input']) {
|
|
121
|
-
this.ui['search-input'].
|
|
122
|
-
this.ui['search-input'].
|
|
123
|
-
this.ui['search-input'].
|
|
121
|
+
this.ui['search-input'].set()
|
|
122
|
+
this.ui['search-input'].show()
|
|
123
|
+
this.ui['search-input'].focus()
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
this.ui.body.innerHTML = ''
|
|
@@ -142,8 +142,8 @@ export default {
|
|
|
142
142
|
this.ui.search.element.classList.remove('selected')
|
|
143
143
|
}
|
|
144
144
|
if (this.ui['search-input']) {
|
|
145
|
-
this.ui['search-input'].
|
|
146
|
-
this.ui['search-input'].
|
|
145
|
+
this.ui['search-input'].hide()
|
|
146
|
+
this.ui['search-input'].set()
|
|
147
147
|
}
|
|
148
148
|
// this.ui['search-list'].classList.remove('show')
|
|
149
149
|
// this.ui.body.classList.remove('hide')
|
package/src/list/select.js
CHANGED
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
// console.log('select', item.dataset.id)
|
|
4
4
|
if (!item || !item.dataset.id) return
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const id = item.dataset.id
|
|
7
7
|
|
|
8
8
|
this.index = this.dataList.indexOf(id)
|
|
9
9
|
this.info = this.dataStore[id]
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const selected = this.ui.body.querySelector('.selected')
|
|
16
16
|
if (selected) selected.classList.remove('selected')
|
|
17
17
|
|
|
18
18
|
if (id) {
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
|
|
33
33
|
unselect () {
|
|
34
34
|
// console.log('unselect')
|
|
35
|
-
|
|
35
|
+
const item = this.ui.body.querySelector('[data-id="' + this.id + '"]') || this.item
|
|
36
36
|
this.id = null
|
|
37
37
|
if (item) {
|
|
38
38
|
item.classList.remove('selected')
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
|
|
52
52
|
getItemById (id, silent) {
|
|
53
53
|
// console.log('selectItemById', id)
|
|
54
|
-
|
|
54
|
+
const item = this.ui.body.querySelector('[data-id="' + id + '"]')
|
|
55
55
|
|
|
56
56
|
if (!item) {
|
|
57
57
|
return null
|
|
@@ -67,7 +67,7 @@ export default {
|
|
|
67
67
|
return false
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
const index = this.dataList.indexOf(id)
|
|
71
71
|
if (index < 0) {
|
|
72
72
|
// console.log('can\'t selectid, not in the list')
|
|
73
73
|
return false
|
|
@@ -83,16 +83,16 @@ export default {
|
|
|
83
83
|
|
|
84
84
|
selectItemById (id, direction) {
|
|
85
85
|
// console.log('selectItemById', id)
|
|
86
|
-
|
|
86
|
+
const item = this.ui.body.querySelector('[data-id="' + id + '"]')
|
|
87
87
|
|
|
88
88
|
this.id = id
|
|
89
89
|
|
|
90
90
|
if (!item) {
|
|
91
|
-
|
|
91
|
+
const index = this.dataList.indexOf(id)
|
|
92
92
|
// console.log('not found in DOM, check in dataList', index)
|
|
93
93
|
if (index > -1) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const listSize = this.options.list.size
|
|
95
|
+
const slice = listSize * index / listSize
|
|
96
96
|
// console.log('getSlice', slice)
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -103,7 +103,7 @@ export default {
|
|
|
103
103
|
|
|
104
104
|
// if (this.item) this.item.classList.remove('selected')
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
const selected = this.ui.body.querySelector('.selected')
|
|
107
107
|
if (selected) selected.classList.remove('selected')
|
|
108
108
|
|
|
109
109
|
this.item = item
|
|
@@ -118,7 +118,7 @@ export default {
|
|
|
118
118
|
},
|
|
119
119
|
|
|
120
120
|
selectPosition (item, direction) {
|
|
121
|
-
|
|
121
|
+
const offsetY = this.options.item.height
|
|
122
122
|
direction = direction || 'down'
|
|
123
123
|
// console.log('selectPosition', this.ui.body, direction)
|
|
124
124
|
|
|
@@ -126,12 +126,12 @@ export default {
|
|
|
126
126
|
|
|
127
127
|
// console.log('coord', this.coord)
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
const itemTop = item.offsetTop + this.coord.top - this.ui.body.scrollTop
|
|
130
130
|
|
|
131
131
|
if (direction === 'down' && itemTop + this.options.item.height + offsetY - this.coord.y > this.coord.height) {
|
|
132
132
|
var top = this.ui.body.scrollTop + itemTop - this.coord.height - this.coord.y + this.options.item.height + offsetY
|
|
133
133
|
this.ui.body.scrollTo({
|
|
134
|
-
top
|
|
134
|
+
top,
|
|
135
135
|
left: 0
|
|
136
136
|
// behavior: 'smooth'
|
|
137
137
|
})
|
|
@@ -142,7 +142,7 @@ export default {
|
|
|
142
142
|
// console.lof('scrollTo', top, item)
|
|
143
143
|
this.ui.body.scrollTo({
|
|
144
144
|
left: 0,
|
|
145
|
-
top
|
|
145
|
+
top
|
|
146
146
|
// behavior: 'smooth'
|
|
147
147
|
})
|
|
148
148
|
}
|
|
@@ -150,9 +150,9 @@ export default {
|
|
|
150
150
|
|
|
151
151
|
selectNext (silent) {
|
|
152
152
|
// console.log('selectNext', this.id)
|
|
153
|
-
|
|
153
|
+
const idx = this.dataList.indexOf(this.id)
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
const id = this.dataList[idx + 1]
|
|
156
156
|
|
|
157
157
|
// console.log('id', id)
|
|
158
158
|
|
|
@@ -172,9 +172,9 @@ export default {
|
|
|
172
172
|
|
|
173
173
|
selectPrevious (silent) {
|
|
174
174
|
// console.log('selectPrevious', this.id)
|
|
175
|
-
|
|
175
|
+
const idx = this.dataList.indexOf(this.id)
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
const id = this.dataList[idx - 1]
|
|
178
178
|
|
|
179
179
|
if (id) {
|
|
180
180
|
this.id = id
|
package/src/list/status.js
CHANGED
package/src/list/update.js
CHANGED
|
@@ -9,8 +9,8 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
getUpdatedIndex (id) {
|
|
11
11
|
// console.log('getUpdatedIndex', id)
|
|
12
|
-
|
|
13
|
-
for (
|
|
12
|
+
let index = null
|
|
13
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
14
14
|
// console.log('--', this.data[i][this.dataId], id)
|
|
15
15
|
if (this.data[i][this.dataId] === id) {
|
|
16
16
|
index = i
|
|
@@ -23,9 +23,9 @@ export default {
|
|
|
23
23
|
|
|
24
24
|
getUpdatedInfo (id) {
|
|
25
25
|
// console.log('getUpdatedInfo', id)
|
|
26
|
-
|
|
26
|
+
const index = this.getUpdatedIndex(id)
|
|
27
27
|
// console.log('index', index)
|
|
28
|
-
|
|
28
|
+
const route = this.buildRoute(index + 1, 1)
|
|
29
29
|
// console.log('roote', route)
|
|
30
30
|
fetch(route).then((resp) => {
|
|
31
31
|
return resp.json()
|
|
@@ -50,10 +50,10 @@ export default {
|
|
|
50
50
|
this.dataStore[info[this.dataId]] = info
|
|
51
51
|
|
|
52
52
|
// update item if on the screen
|
|
53
|
-
|
|
53
|
+
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
|
54
54
|
if (item) {
|
|
55
55
|
item.innerHTML = ''
|
|
56
|
-
|
|
56
|
+
const layout = new Layout(this.options.layout.item, item)
|
|
57
57
|
|
|
58
58
|
this.renderInfo(layout, info)
|
|
59
59
|
}
|