@sedoo/unidoo 0.0.61 → 0.0.65
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/dist/unidoo.common.js +143 -114
- package/dist/unidoo.common.js.map +1 -1
- package/dist/unidoo.umd.js +143 -114
- package/dist/unidoo.umd.js.map +1 -1
- package/dist/unidoo.umd.min.js +2 -2
- package/dist/unidoo.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/unidoo-heatmap/Heatmap.js +1 -1
- package/src/components/unidoo-heatmap/UnidooHeatmap.vue +39 -20
- package/src/components/unidoo-heatmap/date-switcher.vue +28 -23
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ export default class CalendarHeatmap {
|
|
|
8
8
|
this.max = Math.ceil((Math.max(...values.map(day => day.count)) / 5) * 4)
|
|
9
9
|
}
|
|
10
10
|
this.values = values.map(v => { return { date: this._valuesDateFormat(v.date), count: v.count } })
|
|
11
|
-
this.times = this._getTimes(year)
|
|
11
|
+
this.times = this._getTimes(this.year.getFullYear())
|
|
12
12
|
this.times.sort()
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable keyword-spacing */
|
|
1
2
|
<template>
|
|
2
3
|
<v-container>
|
|
3
4
|
<section heatmap-calendar>
|
|
@@ -88,20 +89,21 @@ export default {
|
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
91
|
data: () => ({
|
|
91
|
-
now: new Date(new Date().setHours(23,59,59,999))
|
|
92
|
+
now: new Date(new Date().setHours(23, 59, 59, 999))
|
|
92
93
|
}),
|
|
93
94
|
watch: {
|
|
94
95
|
dateValue (val) {
|
|
95
96
|
this.focusDate(val)
|
|
96
97
|
this.updateDateSwitcher(val)
|
|
97
98
|
},
|
|
98
|
-
year (val) {
|
|
99
|
-
if (val !==
|
|
99
|
+
year (val, old) {
|
|
100
|
+
if (val !== old) {
|
|
100
101
|
const rects = document.querySelectorAll('[heatmap-calendar] [month] .monthday')
|
|
101
102
|
rects.forEach(element => {
|
|
102
103
|
element.classList.remove('day-focus')
|
|
103
104
|
});
|
|
104
105
|
this.focusDate(this.dateValue)
|
|
106
|
+
this.updateDateSwitcher(null)
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
},
|
|
@@ -122,7 +124,7 @@ export default {
|
|
|
122
124
|
return DEFAULT_LOCALE
|
|
123
125
|
},
|
|
124
126
|
dateValue() {
|
|
125
|
-
if(this.value){
|
|
127
|
+
if (this.value) {
|
|
126
128
|
return (this.value instanceof Date) ? this.value : this.value.date;
|
|
127
129
|
} else {
|
|
128
130
|
return this.value;
|
|
@@ -131,17 +133,17 @@ export default {
|
|
|
131
133
|
},
|
|
132
134
|
beforeMount () {
|
|
133
135
|
Plugin.EventBus.$on("unidoo-heatmap-set-date", params => {
|
|
134
|
-
if(this.heatmapKey) {
|
|
135
|
-
if (params.key === this.heatmapKey && params.date){
|
|
136
|
+
if (this.heatmapKey) {
|
|
137
|
+
if (params.key === this.heatmapKey && params.date) {
|
|
136
138
|
this.setDate(params.date)
|
|
137
139
|
}
|
|
138
|
-
} else if(params.date) {
|
|
140
|
+
} else if (params.date) {
|
|
139
141
|
this.setDate(params.date)
|
|
140
142
|
}
|
|
141
143
|
})
|
|
142
144
|
Plugin.EventBus.$on("unidoo-heatmap-get-date", params => {
|
|
143
|
-
if(this.heatmapKey) {
|
|
144
|
-
if (params.key === this.heatmapKey){
|
|
145
|
+
if (this.heatmapKey) {
|
|
146
|
+
if (params.key === this.heatmapKey) {
|
|
145
147
|
this.updateDateSwitcher(this.dateValue)
|
|
146
148
|
}
|
|
147
149
|
} else {
|
|
@@ -184,7 +186,7 @@ export default {
|
|
|
184
186
|
handleClick (e, day) {
|
|
185
187
|
if (day) {
|
|
186
188
|
if (day.date <= this.now && (typeof day.count === 'number' || this.missingAllowed)) {
|
|
187
|
-
if(this.returnObject){
|
|
189
|
+
if (this.returnObject) {
|
|
188
190
|
this.$emit('input', day);
|
|
189
191
|
} else {
|
|
190
192
|
this.$emit('input', day.date);
|
|
@@ -200,22 +202,30 @@ export default {
|
|
|
200
202
|
updateDateSwitcher (d) {
|
|
201
203
|
this.$unidooDateSwitcher.update({
|
|
202
204
|
hasPrevious: this.hasPreviousDate(d),
|
|
203
|
-
hasNext
|
|
204
|
-
previousAvailable
|
|
205
|
-
nextAvailable
|
|
205
|
+
hasNext: this.hasNextDate(d),
|
|
206
|
+
previousAvailable: this.heatmap.getPreviousAvailableDate(d),
|
|
207
|
+
nextAvailable: this.heatmap.getNextAvailableDate(d)
|
|
206
208
|
}, this.heatmapKey);
|
|
207
209
|
},
|
|
208
210
|
hasPreviousDate (d) {
|
|
209
|
-
if(!d || this.
|
|
210
|
-
const
|
|
211
|
-
|
|
211
|
+
if (!d || !this.compairDateWithYear(d)) return false;
|
|
212
|
+
const syear = (this.year instanceof Date) ? this.year.getFullYear() : this.year;
|
|
213
|
+
const firstDay = new Date(syear, 0, 1);
|
|
214
|
+
d.setHours(0, 0, 0, 0);
|
|
215
|
+
if (d <= firstDay) return false;
|
|
212
216
|
return true;
|
|
213
217
|
},
|
|
214
218
|
hasNextDate (d) {
|
|
215
|
-
if(!d || this.
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
if(
|
|
219
|
+
if (!d || !this.isDateInYear(d)) return false;
|
|
220
|
+
const syear = (this.year instanceof Date) ? this.year.getFullYear() : this.year;
|
|
221
|
+
let lastDay = null;
|
|
222
|
+
if (new Date(syear, 0, 1).getFullYear() === new Date().getFullYear()) {
|
|
223
|
+
lastDay = new Date();
|
|
224
|
+
} else {
|
|
225
|
+
lastDay = new Date(syear, 11, 31);
|
|
226
|
+
}
|
|
227
|
+
lastDay.setHours(0, 0, 0, 0);
|
|
228
|
+
if (d >= lastDay) return false;
|
|
219
229
|
return true;
|
|
220
230
|
},
|
|
221
231
|
focusDate (d) {
|
|
@@ -284,6 +294,15 @@ export default {
|
|
|
284
294
|
return first.getFullYear() === second.getFullYear() &&
|
|
285
295
|
first.getMonth() === second.getMonth() &&
|
|
286
296
|
first.getDate() === second.getDate()
|
|
297
|
+
},
|
|
298
|
+
compairDateWithYear (d) {
|
|
299
|
+
if (this.year && d) {
|
|
300
|
+
const sd = '' + ((d instanceof Date) ? d.getFullYear() : d);
|
|
301
|
+
const syear = '' + ((this.year instanceof Date) ? this.year.getFullYear() : this.year);
|
|
302
|
+
return syear === sd;
|
|
303
|
+
} else {
|
|
304
|
+
return false
|
|
305
|
+
}
|
|
287
306
|
}
|
|
288
307
|
}
|
|
289
308
|
}
|
|
@@ -21,8 +21,8 @@ import Plugin from '../../plugin.js'
|
|
|
21
21
|
|
|
22
22
|
export default {
|
|
23
23
|
props: {
|
|
24
|
-
date
|
|
25
|
-
type
|
|
24
|
+
date: {
|
|
25
|
+
type: [String, Date],
|
|
26
26
|
default: null
|
|
27
27
|
},
|
|
28
28
|
heatmapKey: {
|
|
@@ -44,19 +44,21 @@ export default {
|
|
|
44
44
|
},
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
computed:{
|
|
48
|
-
cleanedDate(){
|
|
47
|
+
computed: {
|
|
48
|
+
cleanedDate() {
|
|
49
49
|
return this.cleanDate(this.date);
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
beforeMount () {
|
|
53
53
|
Plugin.EventBus.$on("unidoo-dateswitcher-update", params => {
|
|
54
|
-
if(this.heatmapKey) {
|
|
55
|
-
if (params.key === this.heatmapKey && params.data){
|
|
54
|
+
if (this.heatmapKey) {
|
|
55
|
+
if (params.key === this.heatmapKey && params.data) {
|
|
56
56
|
this.updateNearDates(params.data);
|
|
57
57
|
}
|
|
58
|
-
} else if(params.data) {
|
|
58
|
+
} else if (params.data) {
|
|
59
59
|
this.updateNearDates(params.data);
|
|
60
|
+
} else {
|
|
61
|
+
this.reset();
|
|
60
62
|
}
|
|
61
63
|
})
|
|
62
64
|
},
|
|
@@ -66,31 +68,36 @@ export default {
|
|
|
66
68
|
},
|
|
67
69
|
|
|
68
70
|
methods: {
|
|
69
|
-
|
|
71
|
+
reset() {
|
|
72
|
+
this.hasNext = false
|
|
73
|
+
this.hasPrevious = false
|
|
74
|
+
this.nextAvailable = null
|
|
75
|
+
this.previousAvailable = null
|
|
76
|
+
},
|
|
70
77
|
goToNextAvailable() {
|
|
71
|
-
if(this.hasNext) {
|
|
78
|
+
if (this.hasNext) {
|
|
72
79
|
this.$unidooHeatmap.setDate(this.cleanDate(this.nextAvailable), this.heatmapKey);
|
|
73
80
|
}
|
|
74
81
|
},
|
|
75
82
|
|
|
76
83
|
goToPreviousAvailable() {
|
|
77
|
-
if(this.hasPrevious) {
|
|
84
|
+
if (this.hasPrevious) {
|
|
78
85
|
this.$unidooHeatmap.setDate(this.cleanDate(this.previousAvailable), this.heatmapKey);
|
|
79
86
|
}
|
|
80
87
|
},
|
|
81
88
|
|
|
82
|
-
switchDate(n){
|
|
83
|
-
if(this.cleanedDate && n){
|
|
84
|
-
if((n > 0 && this.hasNext) || (n < 0 && this.hasPrevious)){
|
|
85
|
-
|
|
89
|
+
switchDate(n) {
|
|
90
|
+
if (this.cleanedDate && n) {
|
|
91
|
+
if ((n > 0 && this.hasNext) || (n < 0 && this.hasPrevious)) {
|
|
92
|
+
const newDate = new Date(this.cleanedDate);
|
|
86
93
|
newDate.setDate(this.cleanedDate.getDate() + n);
|
|
87
94
|
this.$unidooHeatmap.setDate(newDate, this.heatmapKey);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
},
|
|
91
98
|
|
|
92
|
-
updateNearDates(data){
|
|
93
|
-
if(data){
|
|
99
|
+
updateNearDates(data) {
|
|
100
|
+
if (data) {
|
|
94
101
|
this.hasNext = data.hasNext
|
|
95
102
|
this.hasPrevious = data.hasPrevious
|
|
96
103
|
this.nextAvailable = data.nextAvailable
|
|
@@ -98,11 +105,11 @@ export default {
|
|
|
98
105
|
}
|
|
99
106
|
},
|
|
100
107
|
|
|
101
|
-
cleanDate(date){
|
|
102
|
-
if(date){
|
|
103
|
-
if(date instanceof Date){
|
|
108
|
+
cleanDate(date) {
|
|
109
|
+
if (date) {
|
|
110
|
+
if (date instanceof Date) {
|
|
104
111
|
return date;
|
|
105
|
-
} else if(typeof date === 'string'){
|
|
112
|
+
} else if (typeof date === 'string') {
|
|
106
113
|
return new Date(date);
|
|
107
114
|
}
|
|
108
115
|
}
|
|
@@ -121,6 +128,4 @@ export default {
|
|
|
121
128
|
background: rgb(245,245,245);
|
|
122
129
|
border-radius: 5px;
|
|
123
130
|
}
|
|
124
|
-
</style>
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
</style>
|