@tak-ps/vue-tabler 3.4.0 → 3.6.0
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/CHANGELOG.md +8 -0
- package/components/None.vue +49 -0
- package/components/Pager.vue +122 -0
- package/lib.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v3.6.0
|
|
14
|
+
|
|
15
|
+
- :rocket: Add `TablerPager` component for iterating over a list
|
|
16
|
+
|
|
17
|
+
### v3.5.0
|
|
18
|
+
|
|
19
|
+
- :rocket: Add `TablerNone` component for use when a list or property is empty
|
|
20
|
+
|
|
13
21
|
### v3.4.0
|
|
14
22
|
|
|
15
23
|
- :rocket: Add `TablerSchema` component for creating forms from basic JSON Schemas
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class='card-body'>
|
|
3
|
+
<div class='d-flex justify-content-center' :class='{
|
|
4
|
+
"mt-4 mb-2": !compact
|
|
5
|
+
}'>
|
|
6
|
+
<NotesOffIcon v-if='compact' width='32' height='32' />
|
|
7
|
+
<NotesOffIcon v-else width='48' height='48' />
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class='text-center' :class='{
|
|
11
|
+
"mb-4 mt-2": !compact
|
|
12
|
+
}'>
|
|
13
|
+
<div>No <span v-text='label'/></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div v-if='create' @click='$emit("create")' class='d-flex justify-content-center my-4' :class='{
|
|
17
|
+
"my-4": !compact
|
|
18
|
+
}'>
|
|
19
|
+
<div class='btn btn-primary'><span>Create <span v-text='label'/></span></div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import {
|
|
26
|
+
NotesOffIcon
|
|
27
|
+
} from 'vue-tabler-icons'
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
name: 'TablerNone',
|
|
31
|
+
props: {
|
|
32
|
+
label: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'Items'
|
|
35
|
+
},
|
|
36
|
+
compact: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
create: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
components: {
|
|
46
|
+
NotesOffIcon
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class='pagination m-0 ms-auto'>
|
|
3
|
+
<div>
|
|
4
|
+
<template v-if='parseInt(total) <= parseInt(limit)'>
|
|
5
|
+
<button @click='page(0)' class='btn mx-1' >
|
|
6
|
+
<HomeIcon class='icon'/>Home
|
|
7
|
+
</button>
|
|
8
|
+
</template>
|
|
9
|
+
<template v-else>
|
|
10
|
+
<button @click='page(0)' class='btn mx-1' :class='{ "btn-primary": current === 0 }'>
|
|
11
|
+
<HomeIcon class='icon'/>Home
|
|
12
|
+
</button>
|
|
13
|
+
|
|
14
|
+
<template v-if='end > 5 && current > 3'>
|
|
15
|
+
<span class=''> ... </span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<template v-if='parseInt(total) / parseInt(limit) > 2'>
|
|
19
|
+
<button
|
|
20
|
+
:key=i
|
|
21
|
+
v-for='i in middle'
|
|
22
|
+
@click='page(i)'
|
|
23
|
+
class='btn mx-1'
|
|
24
|
+
v-text='i + 1'
|
|
25
|
+
:class='{ "btn-primary": current === i }'
|
|
26
|
+
>
|
|
27
|
+
</button>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<template v-if='end > 5 && current < end - spread'>
|
|
31
|
+
<span class=''> ... </span>
|
|
32
|
+
</template>
|
|
33
|
+
<button
|
|
34
|
+
@click='page(end - 1)'
|
|
35
|
+
class='btn mx-1'
|
|
36
|
+
v-text='end'
|
|
37
|
+
:class='{ "btn-primary": current === end - 1 }'
|
|
38
|
+
></button>
|
|
39
|
+
</template>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import {
|
|
46
|
+
HomeIcon
|
|
47
|
+
} from 'vue-tabler-icons';
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
name: 'TablerPager',
|
|
51
|
+
props: [ 'total', 'limit' ],
|
|
52
|
+
data: function() {
|
|
53
|
+
return this.create();
|
|
54
|
+
},
|
|
55
|
+
watch: {
|
|
56
|
+
total: function() {
|
|
57
|
+
const set = this.create();
|
|
58
|
+
|
|
59
|
+
this.spread = set.spread;
|
|
60
|
+
this.middle = set.middle;
|
|
61
|
+
this.current = set.current;
|
|
62
|
+
this.end = set.end;
|
|
63
|
+
},
|
|
64
|
+
limit: function() {
|
|
65
|
+
const set = this.create();
|
|
66
|
+
|
|
67
|
+
this.spread = set.spread;
|
|
68
|
+
this.middle = set.middle;
|
|
69
|
+
this.current = set.current;
|
|
70
|
+
this.end = set.end;
|
|
71
|
+
},
|
|
72
|
+
current: function() {
|
|
73
|
+
if (this.end < 5) return; // All buttons are shown already
|
|
74
|
+
|
|
75
|
+
let start;
|
|
76
|
+
if (this.current <= 3) {
|
|
77
|
+
start = 0;
|
|
78
|
+
} else if (this.current >= this.end - 4) {
|
|
79
|
+
start = this.end - this.spread - 2;
|
|
80
|
+
} else {
|
|
81
|
+
start = this.current - 3;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.middle = this.middle.map((ele, i) => {
|
|
85
|
+
return start + i + 1;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
methods: {
|
|
90
|
+
create: function() {
|
|
91
|
+
const end = Math.ceil(parseInt(this.total) / parseInt(this.limit));
|
|
92
|
+
let spread; //Number of pages in between home button and last page
|
|
93
|
+
if (end <= 2) {
|
|
94
|
+
spread = 0;
|
|
95
|
+
} else if (end >= 7) {
|
|
96
|
+
spread = 5;
|
|
97
|
+
} else {
|
|
98
|
+
spread = end - 2;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Array containing middle page number
|
|
102
|
+
let middleAr = new Array(spread).fill(1, 0, spread).map((ele, i) => {
|
|
103
|
+
return 1 + i;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
spread: spread,
|
|
108
|
+
middle: middleAr,
|
|
109
|
+
current: 0,
|
|
110
|
+
end: end
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
page: function(page) {
|
|
114
|
+
this.current = page;
|
|
115
|
+
this.$emit('page', this.current);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
components: {
|
|
119
|
+
HomeIcon
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</script>
|
package/lib.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { default as TablerPager } from './components/Pager.vue'
|
|
2
|
+
export { default as TablerNone } from './components/None.vue'
|
|
1
3
|
export { default as TablerError } from './components/Err.vue'
|
|
2
4
|
export { default as TablerList } from './components/List.vue'
|
|
3
5
|
export { default as TablerHelp } from './components/Help.vue'
|