@sedoo/unidoo 0.0.38 → 0.0.42

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.38",
3
+ "version": "0.0.42",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "vue-cli-service build --target lib --name unidoo src/plugin.js",
@@ -13,7 +13,7 @@
13
13
  :data-day="formatDate(day.date)"
14
14
  :data-count="day.count"
15
15
  :data-color="day.colorIndex"
16
- :style="{ opacity : ((day.date < now) ? 1 : 0.3), backgroundColor: getColor(day.colorIndex) }"
16
+ :style="{ opacity : ((day.date <= now) ? 1 : 0.3), backgroundColor: getColor(day.colorIndex) }"
17
17
  v-tooltip="tooltipOptions(day)"
18
18
  @click="handleClick($event,day)">
19
19
  <div v-if="day.date < now" :style="{ color: getTextColor(day) }">{{ dayIndex + 1 }}</div>
@@ -86,7 +86,7 @@ export default {
86
86
  }
87
87
  },
88
88
  data: () => ({
89
- now: new Date()
89
+ now: new Date(new Date().setHours(23,59,59,999))
90
90
  }),
91
91
  watch: {
92
92
  dateValue (val) {
@@ -139,7 +139,7 @@ export default {
139
139
  },
140
140
  methods: {
141
141
  computeClass (day) {
142
- return `monthday ${((day.date < this.now) ? 'clickable' : 'not-clickable')} ${(this.isSameDay(day.date, this.dateValue) ? 'day-focus' : '')}`
142
+ return `monthday ${((day.date <= this.now) ? 'clickable' : 'not-clickable')} ${(this.isSameDay(day.date, this.dateValue) ? 'day-focus' : '')}`
143
143
  },
144
144
  tooltipOptions (day) {
145
145
  if (this.tooltip) {
@@ -171,7 +171,7 @@ export default {
171
171
  },
172
172
  handleClick (e, day) {
173
173
  if (day) {
174
- if (day.date < this.now && (typeof day.count === 'number' || this.missingAllowed)) {
174
+ if (day.date <= this.now && (typeof day.count === 'number' || this.missingAllowed)) {
175
175
  if(this.returnObject){
176
176
  this.$emit('input', day);
177
177
  } else {
@@ -278,6 +278,7 @@ export default {
278
278
  }
279
279
  section[heatmap-calendar] [month] .monthday{
280
280
  margin-right: 2px;
281
+ margin-bottom: 2px;
281
282
  width:15px;
282
283
  height:15px;
283
284
  text-align: center;
@@ -55,7 +55,11 @@ export default {
55
55
  watch: {
56
56
  availableOptions(val) {
57
57
  if (val.length) {
58
- this.$emit('input', val[0]);
58
+ if(this.value && val.includes(this.value)){
59
+ this.$emit('input', this.value);
60
+ } else {
61
+ this.$emit('input', val[0]);
62
+ }
59
63
  }
60
64
  }
61
65
 
@@ -53,23 +53,7 @@ export default {
53
53
 
54
54
  selector: {
55
55
  handler(val) {
56
- // update options by level
57
- if (val) {
58
- if (!this.availableOptions) {
59
- this.availableOptions = {};
60
- }
61
- const keys = Object.keys(val);
62
- keys.sort();
63
- const self = this;
64
- keys.forEach(k => {
65
- const values = self.optionsFromLevel(k);
66
- if (JSON.stringify(values) != JSON.stringify(self.availableOptions[k])) {
67
- self.availableOptions[k] = values;
68
- }
69
- })
70
- }
71
- // return data from entries map and selector value
72
- this.$emit('input', this.sort(this.entries[this.getLevelIdFromSelector(val)]));
56
+ this.loadSelector(val);
73
57
  },
74
58
  deep: true
75
59
  },
@@ -98,13 +82,32 @@ export default {
98
82
  }
99
83
  },
100
84
 
85
+ loadSelector(val){
86
+ // update options by level
87
+ if (val) {
88
+ if (!this.availableOptions) {
89
+ this.availableOptions = {};
90
+ }
91
+ const keys = Object.keys(val);
92
+ keys.sort();
93
+ const self = this;
94
+ keys.forEach(k => {
95
+ const values = self.optionsFromLevel(k);
96
+ if (JSON.stringify(values) != JSON.stringify(self.availableOptions[k])) {
97
+ self.availableOptions[k] = values;
98
+ }
99
+ })
100
+ }
101
+ // return data from entries map and selector value
102
+ this.$emit('input', this.sort(this.entries[this.getLevelIdFromSelector(val)]));
103
+ },
104
+
101
105
  initLevels(levels, entries){
102
106
 
103
107
  if(levels.length > 0 && entries.length > 0){
104
108
  this.levelKeys = [];
105
109
  this.levels = {};
106
110
  this.entries = {};
107
- this.selector = {};
108
111
  this.levelOptions = {};
109
112
 
110
113
  levels.forEach(l => {
@@ -113,10 +116,11 @@ export default {
113
116
  });
114
117
 
115
118
  this.levelKeys.sort();
116
-
117
- // init selector using first entry
118
- entries[0].levels.forEach(l => {
119
- this.$set(this.selector, l.name, l.value);
119
+
120
+ // init default selector using first entry
121
+ let defaultSelector = {};
122
+ entries[0].levels.forEach(l => {
123
+ defaultSelector[l.name] = l.value;
120
124
  });
121
125
 
122
126
  // init options tree
@@ -159,8 +163,23 @@ export default {
159
163
  // store data by options combination
160
164
  this.entries[levelId].push(entry);
161
165
  }
166
+
162
167
  });
168
+
163
169
  this.levelOptions = tempOptions;
170
+
171
+ if(this.selector){
172
+ // try to return data from entries map and last selector value
173
+ // else use selector default value
174
+ let lastSelectionEntries = this.entries[this.getLevelIdFromSelector(this.selector)];
175
+ if(lastSelectionEntries && lastSelectionEntries.length > 0){
176
+ this.loadSelector(this.selector);
177
+ } else {
178
+ this.selector = defaultSelector;
179
+ }
180
+ } else {
181
+ this.selector = defaultSelector;
182
+ }
164
183
  }
165
184
  },
166
185