@sedoo/unidoo 0.0.62 → 0.0.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedoo/unidoo",
3
- "version": "0.0.62",
3
+ "version": "0.0.66",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "vue-cli-service build --target lib --name unidoo src/plugin.js",
@@ -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,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 : this.hasNextDate(d),
205
- previousAvailable : this.heatmap.getPreviousAvailableDate(d),
206
- nextAvailable : this.heatmap.getNextAvailableDate(d)
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.compairDateWithYear(d)) return false
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
- if(d <= firstDay) return false;
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.compairDateWithYear(d)) return false
218
- const today = new Date();
219
- today.setHours(0,0,0,0);
220
- if(d >= today) return false;
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
- compairDateWithYear (d) {
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 : [String, Date],
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
- let newDate = new Date(this.cleanedDate);
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>