@tak-ps/vue-tabler 3.1.3 → 3.3.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/Enum.vue +12 -1
- package/components/Epoch.vue +35 -1
- package/components/EpochRange.vue +66 -8
- package/components/Err.vue +1 -0
- package/components/Help.vue +50 -0
- package/components/Input.vue +46 -14
- package/components/List.vue +12 -1
- package/components/Toggle.vue +16 -2
- package/lib.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v3.3.0
|
|
14
|
+
|
|
15
|
+
- :rocket: Add `Human` mode (and make it the default) to `Epoch` and `EpochRange`
|
|
16
|
+
|
|
17
|
+
### v3.2.0
|
|
18
|
+
|
|
19
|
+
- :rocket: Add `required` Property to labelled components
|
|
20
|
+
|
|
13
21
|
### v3.1.3
|
|
14
22
|
|
|
15
23
|
- :bug: `Toggle`: Fix modelValue watch state
|
package/components/Enum.vue
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<label
|
|
3
|
+
<label
|
|
4
|
+
v-if='label'
|
|
5
|
+
class="form-label"
|
|
6
|
+
:class='{
|
|
7
|
+
"required": required
|
|
8
|
+
}'
|
|
9
|
+
v-text='label'
|
|
10
|
+
></label>
|
|
4
11
|
|
|
5
12
|
<select v-model='current' :disabled='disabled' class='form-select'>
|
|
6
13
|
<option v-for='option in options' :value="option" v-text='option'></option>
|
|
@@ -20,6 +27,10 @@ export default {
|
|
|
20
27
|
type: String,
|
|
21
28
|
required: false
|
|
22
29
|
},
|
|
30
|
+
required: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
23
34
|
options: {
|
|
24
35
|
type: Array,
|
|
25
36
|
required: true
|
package/components/Epoch.vue
CHANGED
|
@@ -12,16 +12,50 @@ export default {
|
|
|
12
12
|
},
|
|
13
13
|
format: {
|
|
14
14
|
type: String,
|
|
15
|
-
default: '
|
|
15
|
+
default: 'Human'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
data: function() {
|
|
19
|
+
return {
|
|
20
|
+
suffix: {
|
|
21
|
+
1: 'st',
|
|
22
|
+
2: 'nd',
|
|
23
|
+
3: 'rd'
|
|
24
|
+
},
|
|
25
|
+
months: [
|
|
26
|
+
'January',
|
|
27
|
+
'February',
|
|
28
|
+
'March',
|
|
29
|
+
'April',
|
|
30
|
+
'May',
|
|
31
|
+
'June',
|
|
32
|
+
'July',
|
|
33
|
+
'August',
|
|
34
|
+
'September',
|
|
35
|
+
'October',
|
|
36
|
+
'November',
|
|
37
|
+
'December'
|
|
38
|
+
]
|
|
16
39
|
}
|
|
17
40
|
},
|
|
18
41
|
computed: {
|
|
19
42
|
display: function() {
|
|
20
43
|
const date = new Date(this.date)
|
|
44
|
+
|
|
21
45
|
if (this.format === 'ISO') {
|
|
22
46
|
return date.toISOString()
|
|
23
47
|
.replace('T', ' ')
|
|
24
48
|
.replace(/:[0-9]+\.[0-9]+[A-Z]/, '');
|
|
49
|
+
} else if (this.format === 'Human') {
|
|
50
|
+
const day = String(date.getUTCDate());
|
|
51
|
+
const suffix = this.suffix[day.slice(day.length - 1)] || 'th';
|
|
52
|
+
|
|
53
|
+
const res = `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padEnd(2, '0')}, ${this.months[date.getUTCMonth()]} ${date.getUTCDate()}${suffix}`;
|
|
54
|
+
if (date.getFullYear() === new Date().getFullYear()) {
|
|
55
|
+
return res;
|
|
56
|
+
} else {
|
|
57
|
+
return res + `, ${date.getFullYear()}`;
|
|
58
|
+
}
|
|
25
59
|
} else {
|
|
26
60
|
return date.toString();
|
|
27
61
|
}
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
export default {
|
|
7
7
|
name: 'EpochRange',
|
|
8
8
|
props: {
|
|
9
|
+
format: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: 'Human'
|
|
12
|
+
},
|
|
9
13
|
start: {
|
|
10
14
|
type: Number,
|
|
11
15
|
required: true
|
|
@@ -15,17 +19,71 @@ export default {
|
|
|
15
19
|
required: true
|
|
16
20
|
},
|
|
17
21
|
},
|
|
22
|
+
data: function() {
|
|
23
|
+
return {
|
|
24
|
+
suffix: {
|
|
25
|
+
1: 'st',
|
|
26
|
+
2: 'nd',
|
|
27
|
+
3: 'rd'
|
|
28
|
+
},
|
|
29
|
+
months: [
|
|
30
|
+
'January',
|
|
31
|
+
'February',
|
|
32
|
+
'March',
|
|
33
|
+
'April',
|
|
34
|
+
'May',
|
|
35
|
+
'June',
|
|
36
|
+
'July',
|
|
37
|
+
'August',
|
|
38
|
+
'September',
|
|
39
|
+
'October',
|
|
40
|
+
'November',
|
|
41
|
+
'December'
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
18
45
|
computed: {
|
|
19
46
|
display: function() {
|
|
20
|
-
|
|
21
|
-
|
|
47
|
+
if (this.format === 'ISO') {
|
|
48
|
+
const start = new Date(this.start)
|
|
49
|
+
const end = new Date(this.end)
|
|
50
|
+
|
|
51
|
+
const start_dt = start.toISOString().replace(/[A-Z].*/, '');
|
|
52
|
+
const end_dt = end.toISOString().replace(/[A-Z].*/, '');
|
|
53
|
+
if (start_dt === end_dt) {
|
|
54
|
+
return `${start.toISOString().replace(/[A-Z]/, ' ').replace(/:[0-9]+\.[0-9]+[A-Z]/, '')} - ${end.toISOString().replace(/^.*?[A-Z]/, '').replace(/:[0-9]+\.[0-9]+[A-Z]/, '')}`;
|
|
55
|
+
} else {
|
|
56
|
+
return `${start.toISOString().replace(/[A-Z]/, ' ').replace(/:[0-9]+\.[0-9]+[A-Z]/, '')} - ${end.toISOString().replace(/[A-Z]/, ' ').replace(/:[0-9]+\.[0-9]+[A-Z]/, '')}`;
|
|
57
|
+
}
|
|
58
|
+
} else if (this.format === 'Human') {
|
|
59
|
+
const start = new Date(this.start)
|
|
60
|
+
const end = new Date(this.end)
|
|
61
|
+
|
|
62
|
+
const start_day = String(start.getUTCDate());
|
|
63
|
+
const start_day_suffix = this.suffix[start_day.slice(start_day.length - 1)] || 'th';
|
|
64
|
+
const end_day = String(end.getUTCDate());
|
|
65
|
+
const end_day_suffix = this.suffix[end_day.slice(end_day.length - 1)] || 'th';
|
|
66
|
+
|
|
67
|
+
const start_month = `${this.months[start.getUTCMonth()]} ${start.getUTCDate()}${start_day_suffix}`;
|
|
68
|
+
const end_month = `${this.months[end.getUTCMonth()]} ${end.getUTCDate()}${end_day_suffix}`;
|
|
69
|
+
const start_time = `${String(start.getHours()).padStart(2, '0')}:${String(start.getMinutes()).padEnd(2, '0')}`;
|
|
70
|
+
const end_time = `${String(end.getHours()).padStart(2, '0')}:${String(end.getMinutes()).padEnd(2, '0')}`;
|
|
22
71
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
72
|
+
if (start.getFullYear() === end.getFullYear() && start.getFullYear() === new Date().getFullYear()) {
|
|
73
|
+
if (start.getUTCMonth() === end.getUTCMonth() && start.getUTCDate() === end.getUTCDate()) {
|
|
74
|
+
return `${start_month} ${start_time} - ${end_time}`;
|
|
75
|
+
} else {
|
|
76
|
+
return `${start_month} ${start_time} - ${end_month} ${end_time}`;
|
|
77
|
+
}
|
|
78
|
+
} else if (start.getFullYear() === end.getFullYear()) {
|
|
79
|
+
if (start.getUTCMonth() === end.getUTCMonth() && start.getUTCDate() === end.getUTCDate()) {
|
|
80
|
+
return `${start_month}, ${start.getFullYear()} ${start_time} - ${end_time}`;
|
|
81
|
+
} else {
|
|
82
|
+
return `${start_month}, ${start.getFullYear()} ${start_time} - ${end_month} ${end_time}`;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
return `${start_month} ${start.getFullYear()}, ${start_time} - ${end_month} ${end.getFullYear()}, ${end_time}`;
|
|
86
|
+
}
|
|
29
87
|
}
|
|
30
88
|
}
|
|
31
89
|
}
|
package/components/Err.vue
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal>
|
|
3
|
+
<button type="button" class="btn-close" @click='close' aria-label="Close"></button>
|
|
4
|
+
<div class="modal-status bg-yellow"></div>
|
|
5
|
+
<div class="modal-header d-flex">
|
|
6
|
+
<span class='modal-title' v-text='label'></span>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="modal-body text-center py-4">
|
|
9
|
+
<div class="text-muted" v-text='description'></div>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="modal-footer">
|
|
12
|
+
<div class="w-100">
|
|
13
|
+
<div class="row">
|
|
14
|
+
<div class="col"><a @click='close' class="cursor-pointer btn w-100">OK</a></div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</Modal>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import Modal from './Modal.vue';
|
|
23
|
+
import {
|
|
24
|
+
InfoSquareIcon
|
|
25
|
+
} from 'vue-tabler-icons'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
name: 'TablerHelp',
|
|
29
|
+
props: {
|
|
30
|
+
label: {
|
|
31
|
+
type: String,
|
|
32
|
+
require: false,
|
|
33
|
+
default: 'Help'
|
|
34
|
+
},
|
|
35
|
+
description: {
|
|
36
|
+
type: String,
|
|
37
|
+
require: true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
close: function() {
|
|
42
|
+
this.$emit('close');
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
components: {
|
|
46
|
+
Modal,
|
|
47
|
+
InfoSquareIcon
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
package/components/Input.vue
CHANGED
|
@@ -1,22 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
<template v-if='!rows || rows <= 1'>
|
|
19
|
+
<input :disabled='disabled' :value='modelValue' @input='event => current = event.target.value' :type='type' :class='{
|
|
20
|
+
"is-invalid": error
|
|
21
|
+
}' class="form-control" :placeholder='label||placeholder||""'/>
|
|
22
|
+
</template>
|
|
23
|
+
<template v-else>
|
|
24
|
+
<textarea style='white-space: pre;' :disabled='disabled' :rows='rows' :value='modelValue' @input='event => current = event.target.value' :type='type' :class='{
|
|
25
|
+
"is-invalid": error
|
|
26
|
+
}' class="form-control" :placeholder='label||placeholder||""'/>
|
|
27
|
+
</template>
|
|
28
|
+
<div v-if='error' v-text='error' class="invalid-feedback"></div>
|
|
29
|
+
</div>
|
|
16
30
|
</div>
|
|
17
31
|
</template>
|
|
18
32
|
|
|
19
33
|
<script>
|
|
34
|
+
import {
|
|
35
|
+
InfoSquareIcon
|
|
36
|
+
} from 'vue-tabler-icons';
|
|
37
|
+
import Help from './Help.vue';
|
|
38
|
+
|
|
20
39
|
export default {
|
|
21
40
|
name: 'TablerInput',
|
|
22
41
|
props: {
|
|
@@ -24,10 +43,18 @@ export default {
|
|
|
24
43
|
type: [String, Number],
|
|
25
44
|
required: true
|
|
26
45
|
},
|
|
46
|
+
required: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
27
50
|
disabled: {
|
|
28
51
|
type: Boolean,
|
|
29
52
|
default: false,
|
|
30
53
|
},
|
|
54
|
+
description: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: '',
|
|
57
|
+
},
|
|
31
58
|
rows: {
|
|
32
59
|
type: Number,
|
|
33
60
|
default: 1
|
|
@@ -42,6 +69,7 @@ export default {
|
|
|
42
69
|
},
|
|
43
70
|
data: function() {
|
|
44
71
|
return {
|
|
72
|
+
help: false,
|
|
45
73
|
current: ''
|
|
46
74
|
}
|
|
47
75
|
},
|
|
@@ -62,6 +90,10 @@ export default {
|
|
|
62
90
|
this.$emit('update:modelValue', this.current);
|
|
63
91
|
}
|
|
64
92
|
}
|
|
93
|
+
},
|
|
94
|
+
components: {
|
|
95
|
+
Help,
|
|
96
|
+
InfoSquareIcon
|
|
65
97
|
}
|
|
66
98
|
}
|
|
67
99
|
</script>
|
package/components/List.vue
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="dropdown">
|
|
3
|
-
<label
|
|
3
|
+
<label
|
|
4
|
+
v-if='label'
|
|
5
|
+
class='form-label'
|
|
6
|
+
:class='{
|
|
7
|
+
"required": required
|
|
8
|
+
}'
|
|
9
|
+
v-text='label'
|
|
10
|
+
></label>
|
|
4
11
|
<div type="button" ref='button' id="list-menu-button" data-bs-toggle="dropdown" aria-expanded="false" class='border rounded' style='height: 36px;'>
|
|
5
12
|
<div class='d-flex mx-2'>
|
|
6
13
|
<span v-if='ele' style='padding-top: 6px;' v-text='ele[namekey]'/>
|
|
@@ -41,6 +48,10 @@ export default {
|
|
|
41
48
|
type: String,
|
|
42
49
|
default: ''
|
|
43
50
|
},
|
|
51
|
+
required: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
44
55
|
disabled: {
|
|
45
56
|
type: Boolean,
|
|
46
57
|
default: false
|
package/components/Toggle.vue
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<div class='d-flex align-items-center'>
|
|
4
|
-
<label
|
|
4
|
+
<label
|
|
5
|
+
v-if='label'
|
|
6
|
+
class='form-label my-1 mx-2'
|
|
7
|
+
:class='{
|
|
8
|
+
"required": required
|
|
9
|
+
}'
|
|
10
|
+
v-text='label'
|
|
11
|
+
/>
|
|
5
12
|
<label class="ms-auto form-check form-switch pt-2">
|
|
6
13
|
<input v-model='current' :disabled='disabled' class="form-check-input" type="checkbox">
|
|
7
14
|
</label>
|
|
@@ -21,7 +28,14 @@ export default {
|
|
|
21
28
|
type: Boolean,
|
|
22
29
|
default: false
|
|
23
30
|
},
|
|
24
|
-
|
|
31
|
+
required: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: ''
|
|
38
|
+
}
|
|
25
39
|
},
|
|
26
40
|
data: function() {
|
|
27
41
|
return {
|
package/lib.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as TablerError } from './components/Err.vue'
|
|
2
2
|
export { default as TablerList } from './components/List.vue'
|
|
3
|
+
export { default as TablerHelp } from './components/Help.vue'
|
|
3
4
|
export { default as TablerSelect } from './components/Select.vue'
|
|
4
5
|
export { default as TablerModal } from './components/Modal.vue'
|
|
5
6
|
export { default as TablerProgress } from './components/Progress.vue'
|