@tak-ps/vue-tabler 3.2.0 → 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 +4 -0
- package/components/Epoch.vue +35 -1
- package/components/EpochRange.vue +66 -8
- package/components/Help.vue +50 -0
- package/components/Input.vue +42 -21
- package/lib.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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
|
}
|
|
@@ -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,29 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<
|
|
4
|
-
v-if='
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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>
|
|
23
30
|
</div>
|
|
24
31
|
</template>
|
|
25
32
|
|
|
26
33
|
<script>
|
|
34
|
+
import {
|
|
35
|
+
InfoSquareIcon
|
|
36
|
+
} from 'vue-tabler-icons';
|
|
37
|
+
import Help from './Help.vue';
|
|
38
|
+
|
|
27
39
|
export default {
|
|
28
40
|
name: 'TablerInput',
|
|
29
41
|
props: {
|
|
@@ -39,6 +51,10 @@ export default {
|
|
|
39
51
|
type: Boolean,
|
|
40
52
|
default: false,
|
|
41
53
|
},
|
|
54
|
+
description: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: '',
|
|
57
|
+
},
|
|
42
58
|
rows: {
|
|
43
59
|
type: Number,
|
|
44
60
|
default: 1
|
|
@@ -53,6 +69,7 @@ export default {
|
|
|
53
69
|
},
|
|
54
70
|
data: function() {
|
|
55
71
|
return {
|
|
72
|
+
help: false,
|
|
56
73
|
current: ''
|
|
57
74
|
}
|
|
58
75
|
},
|
|
@@ -73,6 +90,10 @@ export default {
|
|
|
73
90
|
this.$emit('update:modelValue', this.current);
|
|
74
91
|
}
|
|
75
92
|
}
|
|
93
|
+
},
|
|
94
|
+
components: {
|
|
95
|
+
Help,
|
|
96
|
+
InfoSquareIcon
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
</script>
|
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'
|