@sedoo/unidoo 0.0.64 → 0.0.68
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 +133 -141
- package/dist/unidoo.common.js.map +1 -1
- package/dist/unidoo.umd.js +133 -141
- package/dist/unidoo.umd.js.map +1 -1
- package/dist/unidoo.umd.min.js +1 -1
- 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 +13 -6
- package/src/components/unidoo-player/level-selector/level-selector-row.vue +7 -7
- package/src/components/unidoo-player/level-selector/level-selector.vue +39 -50
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>
|
|
@@ -207,7 +208,7 @@ export default {
|
|
|
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,10 +216,16 @@ export default {
|
|
|
215
216
|
return true;
|
|
216
217
|
},
|
|
217
218
|
hasNextDate (d) {
|
|
218
|
-
if (!d || !this.
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
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;
|
|
222
229
|
return true;
|
|
223
230
|
},
|
|
224
231
|
focusDate (d) {
|
|
@@ -288,7 +295,7 @@ export default {
|
|
|
288
295
|
first.getMonth() === second.getMonth() &&
|
|
289
296
|
first.getDate() === second.getDate()
|
|
290
297
|
},
|
|
291
|
-
|
|
298
|
+
isDateInYear (d) {
|
|
292
299
|
if (this.year && d) {
|
|
293
300
|
const sd = '' + ((d instanceof Date) ? d.getFullYear() : d);
|
|
294
301
|
const syear = '' + ((this.year instanceof Date) ? this.year.getFullYear() : this.year);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div selector-row>
|
|
3
|
-
<
|
|
3
|
+
<div container>
|
|
4
4
|
|
|
5
5
|
<span label>{{label}} : </span>
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
>{{key}}</span>
|
|
22
22
|
</span>
|
|
23
23
|
|
|
24
|
-
</
|
|
24
|
+
</div>
|
|
25
25
|
|
|
26
26
|
</div>
|
|
27
27
|
</template>
|
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
watch: {
|
|
56
56
|
availableOptions(val) {
|
|
57
57
|
if (val.length) {
|
|
58
|
-
if(this.value && val.includes(this.value)){
|
|
58
|
+
if (this.value && val.includes(this.value)) {
|
|
59
59
|
this.$emit('input', this.value);
|
|
60
60
|
} else {
|
|
61
61
|
this.$emit('input', val[0]);
|
|
@@ -67,14 +67,14 @@ export default {
|
|
|
67
67
|
|
|
68
68
|
methods: {
|
|
69
69
|
|
|
70
|
-
emitInput(key, available){
|
|
71
|
-
if(available){
|
|
70
|
+
emitInput(key, available) {
|
|
71
|
+
if (available) {
|
|
72
72
|
this.$emit('input', key);
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
|
|
76
76
|
focus(key) {
|
|
77
|
-
return this.value
|
|
77
|
+
return this.value === key ? 'level-focused' : '';
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -87,6 +87,7 @@ export default {
|
|
|
87
87
|
|
|
88
88
|
[selector-row] [container]{
|
|
89
89
|
display: flex;
|
|
90
|
+
flex-wrap: wrap;
|
|
90
91
|
justify-items: center;
|
|
91
92
|
align-items: center;
|
|
92
93
|
}
|
|
@@ -139,4 +140,3 @@ export default {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
</style>
|
|
142
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div selector>
|
|
3
3
|
<v-col level-selector v-if="levels && data">
|
|
4
4
|
|
|
5
|
-
<
|
|
5
|
+
<div style="display: flex; flex-wrap: wrap; margin: 0 -12px;" v-for="(key) in levelKeys"
|
|
6
6
|
:key="key"
|
|
7
7
|
>
|
|
8
8
|
<level-selector-row
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:options="getAllOptions(key)"
|
|
13
13
|
></level-selector-row>
|
|
14
14
|
|
|
15
|
-
</
|
|
15
|
+
</div>
|
|
16
16
|
</v-col>
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
type: Array
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
-
showUnavailable:{
|
|
34
|
+
showUnavailable: {
|
|
35
35
|
type: Boolean,
|
|
36
36
|
default: true
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
selector: null,
|
|
42
42
|
levelOptions: null, // tree used to update options
|
|
43
43
|
options: null,
|
|
44
|
-
entries:
|
|
44
|
+
entries: null,
|
|
45
45
|
levelKeys: null,
|
|
46
46
|
availableOptions: null
|
|
47
47
|
}),
|
|
@@ -60,16 +60,16 @@ export default {
|
|
|
60
60
|
|
|
61
61
|
},
|
|
62
62
|
|
|
63
|
-
mounted(){
|
|
63
|
+
mounted() {
|
|
64
64
|
this.initData(this.data);
|
|
65
65
|
},
|
|
66
66
|
|
|
67
67
|
methods: {
|
|
68
68
|
|
|
69
69
|
initData(data) {
|
|
70
|
-
if(data){
|
|
71
|
-
if(data.entries && data.entries.length){
|
|
72
|
-
if(data.levels){
|
|
70
|
+
if (data) {
|
|
71
|
+
if (data.entries && data.entries.length) {
|
|
72
|
+
if (data.levels) {
|
|
73
73
|
this.initLevels(data.levels, data.entries);
|
|
74
74
|
} else {
|
|
75
75
|
this.$emit('input', this.sort(data.entries));
|
|
@@ -82,7 +82,7 @@ export default {
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
|
|
85
|
-
loadSelector(val){
|
|
85
|
+
loadSelector(val) {
|
|
86
86
|
// update options by level
|
|
87
87
|
if (val) {
|
|
88
88
|
if (!this.availableOptions) {
|
|
@@ -93,7 +93,7 @@ export default {
|
|
|
93
93
|
const self = this;
|
|
94
94
|
keys.forEach(k => {
|
|
95
95
|
const values = self.optionsFromLevel(k);
|
|
96
|
-
if (JSON.stringify(values)
|
|
96
|
+
if (JSON.stringify(values) !== JSON.stringify(self.availableOptions[k])) {
|
|
97
97
|
self.availableOptions[k] = values;
|
|
98
98
|
}
|
|
99
99
|
})
|
|
@@ -102,9 +102,8 @@ export default {
|
|
|
102
102
|
this.$emit('input', this.sort(this.entries[this.getLevelIdFromSelector(val)]));
|
|
103
103
|
},
|
|
104
104
|
|
|
105
|
-
initLevels(levels, entries){
|
|
106
|
-
|
|
107
|
-
if(levels.length > 0 && entries.length > 0){
|
|
105
|
+
initLevels(levels, entries) {
|
|
106
|
+
if (levels.length > 0 && entries.length > 0) {
|
|
108
107
|
this.levelKeys = [];
|
|
109
108
|
this.levels = {};
|
|
110
109
|
this.entries = {};
|
|
@@ -112,67 +111,61 @@ export default {
|
|
|
112
111
|
|
|
113
112
|
levels.forEach(l => {
|
|
114
113
|
this.levelKeys.push(l.name);
|
|
115
|
-
this.levels[l.name] = { label
|
|
114
|
+
this.levels[l.name] = { label: l.label };
|
|
116
115
|
});
|
|
117
116
|
|
|
118
117
|
this.levelKeys.sort();
|
|
119
118
|
|
|
120
119
|
// init default selector using first entry
|
|
121
|
-
|
|
120
|
+
const defaultSelector = {};
|
|
122
121
|
entries[0].levels.forEach(l => {
|
|
123
122
|
defaultSelector[l.name] = l.value;
|
|
124
123
|
});
|
|
125
124
|
|
|
126
125
|
// init options tree
|
|
127
|
-
|
|
126
|
+
const tempOptions = {};
|
|
128
127
|
entries.forEach(entry => {
|
|
129
|
-
if(entry.levels){
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
let entryLevels = [...entry.levels];
|
|
128
|
+
if (entry.levels) {
|
|
129
|
+
const entryLevels = [...entry.levels];
|
|
133
130
|
entryLevels.sort((a, b) => b.name.localeCompare(a.name));
|
|
134
131
|
|
|
135
132
|
let branch = null;
|
|
136
133
|
entryLevels.forEach(l => {
|
|
137
|
-
|
|
134
|
+
const tuple = {};
|
|
138
135
|
tuple[l.value] = branch
|
|
139
136
|
branch = tuple;
|
|
140
|
-
|
|
141
137
|
});
|
|
142
138
|
|
|
143
139
|
this.mergeDeep(tempOptions, branch);
|
|
144
140
|
|
|
145
|
-
|
|
141
|
+
const curLevels = entry.levels;
|
|
146
142
|
curLevels.sort((a, b) => a.name.localeCompare(b.name));
|
|
147
143
|
|
|
148
144
|
let levelId = '';
|
|
149
145
|
curLevels.forEach(l => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if(!this.levels[l.name].values) this.levels[l.name].values = [];
|
|
146
|
+
if (this.levels[l.name]) {
|
|
147
|
+
if (!this.levels[l.name].values) this.levels[l.name].values = [];
|
|
153
148
|
this.pushIfNotExist(this.levels[l.name].values, l.value);
|
|
154
|
-
|
|
155
149
|
}
|
|
156
150
|
|
|
157
151
|
// compute id with options combination
|
|
158
152
|
levelId += ((levelId) ? SEPARATOR : '') + l.value;
|
|
159
153
|
});
|
|
160
154
|
|
|
161
|
-
if(!this.entries[levelId]) this.entries[levelId] = [];
|
|
155
|
+
if (!this.entries[levelId]) this.entries[levelId] = [];
|
|
162
156
|
|
|
163
157
|
// store data by options combination
|
|
164
158
|
this.entries[levelId].push(entry);
|
|
165
159
|
}
|
|
166
|
-
|
|
167
160
|
});
|
|
168
161
|
|
|
169
162
|
this.levelOptions = tempOptions;
|
|
170
163
|
|
|
171
|
-
if(this.selector){
|
|
164
|
+
if (this.selector) {
|
|
172
165
|
// try to return data from entries map and last selector value
|
|
173
166
|
// else use selector default value
|
|
174
|
-
|
|
175
|
-
if(lastSelectionEntries && lastSelectionEntries.length > 0){
|
|
167
|
+
const lastSelectionEntries = this.entries[this.getLevelIdFromSelector(this.selector)];
|
|
168
|
+
if (lastSelectionEntries && lastSelectionEntries.length > 0) {
|
|
176
169
|
this.loadSelector(this.selector);
|
|
177
170
|
} else {
|
|
178
171
|
this.selector = defaultSelector;
|
|
@@ -195,7 +188,7 @@ export default {
|
|
|
195
188
|
const sourceValue = source[key];
|
|
196
189
|
|
|
197
190
|
if (isObject(targetValue) && isObject(sourceValue)) {
|
|
198
|
-
|
|
191
|
+
const t = Object.assign({}, targetValue);
|
|
199
192
|
target[key] = this.mergeDeep(t, sourceValue);
|
|
200
193
|
} else {
|
|
201
194
|
target[key] = sourceValue;
|
|
@@ -205,10 +198,10 @@ export default {
|
|
|
205
198
|
return target;
|
|
206
199
|
},
|
|
207
200
|
|
|
208
|
-
getLevelIdFromSelector(selectorValue){
|
|
201
|
+
getLevelIdFromSelector(selectorValue) {
|
|
209
202
|
let levelId = '';
|
|
210
|
-
if(selectorValue){
|
|
211
|
-
|
|
203
|
+
if (selectorValue) {
|
|
204
|
+
const keys = Object.keys(selectorValue);
|
|
212
205
|
keys.sort();
|
|
213
206
|
|
|
214
207
|
keys.forEach(k => {
|
|
@@ -218,21 +211,20 @@ export default {
|
|
|
218
211
|
return levelId;
|
|
219
212
|
},
|
|
220
213
|
|
|
221
|
-
optionsFromLevel(key){
|
|
222
|
-
if(this.levelOptions && this.selector){
|
|
223
|
-
|
|
214
|
+
optionsFromLevel(key) {
|
|
215
|
+
if (this.levelOptions && this.selector) {
|
|
224
216
|
const selectorKeys = Object.keys(this.selector);
|
|
225
217
|
selectorKeys.sort();
|
|
226
218
|
|
|
227
219
|
const index = selectorKeys.indexOf(key);
|
|
228
|
-
const indexes = selectorKeys.slice(0,index);
|
|
220
|
+
const indexes = selectorKeys.slice(0, index);
|
|
229
221
|
|
|
230
222
|
// traverse levelOptions by level using selector values
|
|
231
223
|
let result = this.levelOptions;
|
|
232
224
|
const self = this;
|
|
233
225
|
indexes.forEach(k => {
|
|
234
226
|
const tmp = result[self.selector[k]];
|
|
235
|
-
if(tmp){
|
|
227
|
+
if (tmp) {
|
|
236
228
|
result = tmp;
|
|
237
229
|
} else {
|
|
238
230
|
result = result[Object.keys(result)[0]];
|
|
@@ -243,8 +235,8 @@ export default {
|
|
|
243
235
|
}
|
|
244
236
|
},
|
|
245
237
|
|
|
246
|
-
getAllOptions(key){
|
|
247
|
-
if(this.showUnavailable && this.levels[key]){
|
|
238
|
+
getAllOptions(key) {
|
|
239
|
+
if (this.showUnavailable && this.levels[key]) {
|
|
248
240
|
return this.levels[key].values;
|
|
249
241
|
} else {
|
|
250
242
|
return null;
|
|
@@ -257,9 +249,9 @@ export default {
|
|
|
257
249
|
}
|
|
258
250
|
},
|
|
259
251
|
|
|
260
|
-
sort(array){
|
|
252
|
+
sort(array) {
|
|
261
253
|
if (array) {
|
|
262
|
-
if (array.length > 1){
|
|
254
|
+
if (array.length > 1) {
|
|
263
255
|
let compare = null;
|
|
264
256
|
|
|
265
257
|
compare = function(a, b) {
|
|
@@ -271,10 +263,10 @@ export default {
|
|
|
271
263
|
second = parseInt(b.type);
|
|
272
264
|
}
|
|
273
265
|
|
|
274
|
-
if (
|
|
266
|
+
if (first > second) {
|
|
275
267
|
return 1;
|
|
276
268
|
}
|
|
277
|
-
if (
|
|
269
|
+
if (first < second) {
|
|
278
270
|
return -1;
|
|
279
271
|
}
|
|
280
272
|
return 0;
|
|
@@ -287,14 +279,11 @@ export default {
|
|
|
287
279
|
} else {
|
|
288
280
|
return array;
|
|
289
281
|
}
|
|
290
|
-
|
|
291
282
|
},
|
|
292
283
|
}
|
|
293
284
|
|
|
294
285
|
}
|
|
295
286
|
</script>
|
|
296
287
|
<style scoped>
|
|
297
|
-
|
|
298
288
|
|
|
299
289
|
</style>
|
|
300
|
-
|