@tak-ps/vue-tabler 3.5.0 → 3.7.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 CHANGED
@@ -10,6 +10,14 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v3.7.0
14
+
15
+ - :rocket: Include `description` and `required` to `TablerSchema` and sub components
16
+
17
+ ### v3.6.0
18
+
19
+ - :rocket: Add `TablerPager` component for iterating over a list
20
+
13
21
  ### v3.5.0
14
22
 
15
23
  - :rocket: Add `TablerNone` component for use when a list or property is empty
@@ -1,17 +1,24 @@
1
1
  <template>
2
- <div>
3
- <label
4
- v-if='label'
5
- class="form-label"
6
- :class='{
7
- "required": required
8
- }'
9
- v-text='label'
10
- ></label>
11
-
12
- <select v-model='current' :disabled='disabled' class='form-select'>
13
- <option v-for='option in options' :value="option" v-text='option'></option>
14
- </select>
2
+ <div class='row'>
3
+ <div class='col-12 d-flex'>
4
+ <span v-if='description' style='margin-right: 4px;'>
5
+ <InfoSquareIcon @click='help = true' size='20' class='cursor-pointer'/>
6
+ <Help v-if='help' @click='help = false' :label='label || placeholder' :description='description'/>
7
+ </span>
8
+ <label
9
+ v-if='label'
10
+ class="form-label"
11
+ v-text='label'
12
+ :class='{
13
+ "required": required
14
+ }'
15
+ ></label>
16
+ </div>
17
+ <div class='col-12'>
18
+ <select v-model='current' :disabled='disabled' class='form-select'>
19
+ <option v-for='option in options' :value="option" v-text='option'></option>
20
+ </select>
21
+ </div>
15
22
  </div>
16
23
  </template>
17
24
 
@@ -31,6 +38,10 @@ export default {
31
38
  type: Boolean,
32
39
  required: false
33
40
  },
41
+ description: {
42
+ type: String,
43
+ required: false
44
+ },
34
45
  options: {
35
46
  type: Array,
36
47
  required: true
@@ -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>
@@ -5,16 +5,30 @@
5
5
  <TablerEnum
6
6
  :label='key'
7
7
  :disabled='disabled'
8
+ :required='schema.properties[key].required'
9
+ :description='schema.properties[key].description'
8
10
  v-model='data[key]'
9
11
  :options='schema.properties[key].enum'
10
12
  :default='schema.properties[key].default'
11
13
  />
12
14
  </template>
13
15
  <template v-else-if='schema.properties[key].type === "string"'>
14
- <TablerInput :label='key' :disabled='disabled' v-model='data[key]'/>
16
+ <TablerInput
17
+ :label='key'
18
+ :disabled='disabled'
19
+ :required='schema.properties[key].required'
20
+ :description='schema.properties[key].description'
21
+ v-model='data[key]'
22
+ />
15
23
  </template>
16
24
  <template v-else-if='schema.properties[key].type === "boolean"'>
17
- <TablerToggle :label='key' :disabled='disabled' v-model='data[key]'/>
25
+ <TablerToggle
26
+ :label='key'
27
+ :disabled='disabled'
28
+ :required='schema.properties[key].required'
29
+ :description='schema.properties[key].description'
30
+ v-model='data[key]'
31
+ />
18
32
  </template>
19
33
  <template v-else-if='schema.properties[key].type === "array"'>
20
34
  <div class='d-flex'>
@@ -37,7 +51,11 @@
37
51
  </template>
38
52
  <template v-else>
39
53
  <div class='row'>
40
- <TablerInput :label='key' :rows='3' :disabled='disabled' v-model='data[key]'/>
54
+ <TablerInput
55
+ :label='key'
56
+ :rows='3'
57
+ :disabled='disabled'
58
+ v-model='data[key]'/>
41
59
  </div>
42
60
  </template>
43
61
  </div>
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <div>
3
3
  <div class='d-flex align-items-center'>
4
+ <span v-if='description' style='margin-right: 4px;'>
5
+ <InfoSquareIcon @click='help = true' size='20' class='cursor-pointer'/>
6
+ <Help v-if='help' @click='help = false' :label='label || placeholder' :description='description'/>
7
+ </span>
4
8
  <label
5
9
  v-if='label'
6
10
  class='form-label my-1 mx-2'
@@ -32,6 +36,10 @@ export default {
32
36
  type: Boolean,
33
37
  default: false
34
38
  },
39
+ description: {
40
+ type: String,
41
+ default: false
42
+ },
35
43
  label: {
36
44
  type: String,
37
45
  default: ''
package/lib.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as TablerPager } from './components/Pager.vue'
1
2
  export { default as TablerNone } from './components/None.vue'
2
3
  export { default as TablerError } from './components/Err.vue'
3
4
  export { default as TablerList } from './components/List.vue'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "3.5.0",
4
+ "version": "3.7.0",
5
5
  "lib": "lib.js",
6
6
  "module": "lib.js",
7
7
  "description": "Tabler UI components for Vue3",