@sedoo/unidoo 0.0.41 → 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.41",
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",
@@ -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,6 +82,26 @@ 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){
@@ -161,19 +165,21 @@ export default {
161
165
  }
162
166
 
163
167
  });
168
+
169
+ this.levelOptions = tempOptions;
170
+
164
171
  if(this.selector){
165
172
  // try to return data from entries map and last selector value
166
173
  // else use selector default value
167
174
  let lastSelectionEntries = this.entries[this.getLevelIdFromSelector(this.selector)];
168
175
  if(lastSelectionEntries && lastSelectionEntries.length > 0){
169
- this.$emit('input', this.sort(lastSelectionEntries));
176
+ this.loadSelector(this.selector);
170
177
  } else {
171
178
  this.selector = defaultSelector;
172
179
  }
173
180
  } else {
174
181
  this.selector = defaultSelector;
175
182
  }
176
- this.levelOptions = tempOptions;
177
183
  }
178
184
  },
179
185