@sedoo/unidoo 0.0.63 → 0.0.67
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 +108 -98
- package/dist/unidoo.common.js.map +1 -1
- package/dist/unidoo.umd.js +108 -98
- 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 +5 -5
- package/src/components/unidoo-heatmap/UnidooHeatmap.vue +27 -19
- package/src/components/unidoo-heatmap/date-switcher.vue +21 -23
package/package.json
CHANGED
|
@@ -92,13 +92,13 @@ export default class CalendarHeatmap {
|
|
|
92
92
|
const maxIndex = this.times.length - 1
|
|
93
93
|
let n = index + 1
|
|
94
94
|
if (countGreaterThanZero) {
|
|
95
|
-
while (n
|
|
95
|
+
while (n <= maxIndex) {
|
|
96
96
|
const curr = this.times[n]
|
|
97
97
|
if (curr.endsWith('i')) return this._decodeDate(curr)
|
|
98
98
|
n++
|
|
99
99
|
}
|
|
100
100
|
} else {
|
|
101
|
-
while (n
|
|
101
|
+
while (n <= maxIndex) {
|
|
102
102
|
const curr = this.times[n]
|
|
103
103
|
if (!curr.endsWith('n')) return this._decodeDate(curr)
|
|
104
104
|
n++
|
|
@@ -117,16 +117,16 @@ export default class CalendarHeatmap {
|
|
|
117
117
|
let index = this.times.indexOf(this._encodeDate(date, null))
|
|
118
118
|
if (index < 0) index = this.times.indexOf(this._encodeDate(date, 1))
|
|
119
119
|
if (index < 0) index = this.times.indexOf(this._encodeDate(date, 0))
|
|
120
|
-
if (index
|
|
120
|
+
if (index >= 0) {
|
|
121
121
|
let n = index - 1
|
|
122
122
|
if (countGreaterThanZero) {
|
|
123
|
-
while (n
|
|
123
|
+
while (n >= 0) {
|
|
124
124
|
const curr = this.times[n]
|
|
125
125
|
if (curr.endsWith('i')) return this._decodeDate(curr)
|
|
126
126
|
n--
|
|
127
127
|
}
|
|
128
128
|
} else {
|
|
129
|
-
while (n
|
|
129
|
+
while (n >= 0) {
|
|
130
130
|
const curr = this.times[n]
|
|
131
131
|
if (!curr.endsWith('n')) return this._decodeDate(curr)
|
|
132
132
|
n--
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable keyword-spacing */
|
|
1
2
|
<template>
|
|
2
3
|
<v-container>
|
|
3
4
|
<section heatmap-calendar>
|
|
@@ -88,7 +89,7 @@ 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) {
|
|
@@ -123,7 +124,7 @@ export default {
|
|
|
123
124
|
return DEFAULT_LOCALE
|
|
124
125
|
},
|
|
125
126
|
dateValue() {
|
|
126
|
-
if(this.value){
|
|
127
|
+
if (this.value) {
|
|
127
128
|
return (this.value instanceof Date) ? this.value : this.value.date;
|
|
128
129
|
} else {
|
|
129
130
|
return this.value;
|
|
@@ -132,17 +133,17 @@ export default {
|
|
|
132
133
|
},
|
|
133
134
|
beforeMount () {
|
|
134
135
|
Plugin.EventBus.$on("unidoo-heatmap-set-date", params => {
|
|
135
|
-
if(this.heatmapKey) {
|
|
136
|
-
if (params.key === this.heatmapKey && params.date){
|
|
136
|
+
if (this.heatmapKey) {
|
|
137
|
+
if (params.key === this.heatmapKey && params.date) {
|
|
137
138
|
this.setDate(params.date)
|
|
138
139
|
}
|
|
139
|
-
} else if(params.date) {
|
|
140
|
+
} else if (params.date) {
|
|
140
141
|
this.setDate(params.date)
|
|
141
142
|
}
|
|
142
143
|
})
|
|
143
144
|
Plugin.EventBus.$on("unidoo-heatmap-get-date", params => {
|
|
144
|
-
if(this.heatmapKey) {
|
|
145
|
-
if (params.key === this.heatmapKey){
|
|
145
|
+
if (this.heatmapKey) {
|
|
146
|
+
if (params.key === this.heatmapKey) {
|
|
146
147
|
this.updateDateSwitcher(this.dateValue)
|
|
147
148
|
}
|
|
148
149
|
} else {
|
|
@@ -185,7 +186,7 @@ export default {
|
|
|
185
186
|
handleClick (e, day) {
|
|
186
187
|
if (day) {
|
|
187
188
|
if (day.date <= this.now && (typeof day.count === 'number' || this.missingAllowed)) {
|
|
188
|
-
if(this.returnObject){
|
|
189
|
+
if (this.returnObject) {
|
|
189
190
|
this.$emit('input', day);
|
|
190
191
|
} else {
|
|
191
192
|
this.$emit('input', day.date);
|
|
@@ -201,23 +202,30 @@ export default {
|
|
|
201
202
|
updateDateSwitcher (d) {
|
|
202
203
|
this.$unidooDateSwitcher.update({
|
|
203
204
|
hasPrevious: this.hasPreviousDate(d),
|
|
204
|
-
hasNext
|
|
205
|
-
previousAvailable
|
|
206
|
-
nextAvailable
|
|
205
|
+
hasNext: this.hasNextDate(d),
|
|
206
|
+
previousAvailable: this.heatmap.getPreviousAvailableDate(d),
|
|
207
|
+
nextAvailable: this.heatmap.getNextAvailableDate(d)
|
|
207
208
|
}, this.heatmapKey);
|
|
208
209
|
},
|
|
209
210
|
hasPreviousDate (d) {
|
|
210
|
-
if(!d || !this.
|
|
211
|
+
if (!d || !this.isDateInYear(d)) return false;
|
|
211
212
|
const syear = (this.year instanceof Date) ? this.year.getFullYear() : this.year;
|
|
212
213
|
const firstDay = new Date(syear, 0, 1);
|
|
213
|
-
|
|
214
|
+
d.setHours(0, 0, 0, 0);
|
|
215
|
+
if (d <= firstDay) return false;
|
|
214
216
|
return true;
|
|
215
217
|
},
|
|
216
218
|
hasNextDate (d) {
|
|
217
|
-
if(!d || !this.
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
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;
|
|
221
229
|
return true;
|
|
222
230
|
},
|
|
223
231
|
focusDate (d) {
|
|
@@ -287,8 +295,8 @@ export default {
|
|
|
287
295
|
first.getMonth() === second.getMonth() &&
|
|
288
296
|
first.getDate() === second.getDate()
|
|
289
297
|
},
|
|
290
|
-
|
|
291
|
-
if(this.year && d){
|
|
298
|
+
isDateInYear (d) {
|
|
299
|
+
if (this.year && d) {
|
|
292
300
|
const sd = '' + ((d instanceof Date) ? d.getFullYear() : d);
|
|
293
301
|
const syear = '' + ((this.year instanceof Date) ? this.year.getFullYear() : this.year);
|
|
294
302
|
return syear === sd;
|
|
@@ -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,18 +44,18 @@ 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
60
|
} else {
|
|
61
61
|
this.reset();
|
|
@@ -68,36 +68,36 @@ export default {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
methods: {
|
|
71
|
-
reset(){
|
|
71
|
+
reset() {
|
|
72
72
|
this.hasNext = false
|
|
73
73
|
this.hasPrevious = false
|
|
74
74
|
this.nextAvailable = null
|
|
75
75
|
this.previousAvailable = null
|
|
76
76
|
},
|
|
77
77
|
goToNextAvailable() {
|
|
78
|
-
if(this.hasNext) {
|
|
78
|
+
if (this.hasNext) {
|
|
79
79
|
this.$unidooHeatmap.setDate(this.cleanDate(this.nextAvailable), this.heatmapKey);
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
goToPreviousAvailable() {
|
|
84
|
-
if(this.hasPrevious) {
|
|
84
|
+
if (this.hasPrevious) {
|
|
85
85
|
this.$unidooHeatmap.setDate(this.cleanDate(this.previousAvailable), this.heatmapKey);
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
|
|
89
|
-
switchDate(n){
|
|
90
|
-
if(this.cleanedDate && n){
|
|
91
|
-
if((n > 0 && this.hasNext) || (n < 0 && this.hasPrevious)){
|
|
92
|
-
|
|
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);
|
|
93
93
|
newDate.setDate(this.cleanedDate.getDate() + n);
|
|
94
94
|
this.$unidooHeatmap.setDate(newDate, this.heatmapKey);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
|
|
99
|
-
updateNearDates(data){
|
|
100
|
-
if(data){
|
|
99
|
+
updateNearDates(data) {
|
|
100
|
+
if (data) {
|
|
101
101
|
this.hasNext = data.hasNext
|
|
102
102
|
this.hasPrevious = data.hasPrevious
|
|
103
103
|
this.nextAvailable = data.nextAvailable
|
|
@@ -105,11 +105,11 @@ export default {
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
|
|
108
|
-
cleanDate(date){
|
|
109
|
-
if(date){
|
|
110
|
-
if(date instanceof Date){
|
|
108
|
+
cleanDate(date) {
|
|
109
|
+
if (date) {
|
|
110
|
+
if (date instanceof Date) {
|
|
111
111
|
return date;
|
|
112
|
-
} else if(typeof date === 'string'){
|
|
112
|
+
} else if (typeof date === 'string') {
|
|
113
113
|
return new Date(date);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -128,6 +128,4 @@ export default {
|
|
|
128
128
|
background: rgb(245,245,245);
|
|
129
129
|
border-radius: 5px;
|
|
130
130
|
}
|
|
131
|
-
</style>
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
</style>
|