@signal24/vue-foundation 3.3.4 → 3.6.0

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": "@signal24/vue-foundation",
3
- "version": "3.3.4",
3
+ "version": "3.6.0",
4
4
  "description": "Common components, directives, and helpers for Vue 3 apps",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -8,21 +8,21 @@
8
8
  },
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "axios": "^0.21.1",
11
+ "axios": "^0.26.0",
12
12
  "jquery": "^3.6.0",
13
13
  "lodash": "^4.17.21",
14
14
  "moment": "^2.29.1",
15
- "vue": "^3.2.29",
16
15
  "vue-stash-nested": "fergusean/vue-stash-nested#vue-foundation-3"
17
16
  },
18
17
  "devDependencies": {
19
- "@vue/eslint-config-prettier": "^6.0.0",
20
- "eslint": "^7.32.0",
21
- "eslint-plugin-prettier": "^3.4.1",
18
+ "@vue/eslint-config-prettier": "^7.0.0",
19
+ "eslint": "^8.10.0",
20
+ "eslint-plugin-prettier": "^4.0.0",
22
21
  "eslint-plugin-simple-import-sort": "^7.0.0",
23
- "eslint-plugin-vue": "^7.20.0",
22
+ "eslint-plugin-vue": "^8.5.0",
24
23
  "prettier": "^2.5.1",
25
- "sass": "^1.49.7",
26
- "sass-loader": "^10"
24
+ "sass": "^1.49.9",
25
+ "sass-loader": "^12",
26
+ "vue": "^3.2.31"
27
27
  }
28
28
  }
@@ -41,10 +41,10 @@ import debounce from 'lodash/debounce';
41
41
  const nullSymbol = Symbol(null);
42
42
  const createSymbol = Symbol('create');
43
43
 
44
- const VALID_KEYS = `\`1234567890-=[]\;',./~!@#$%^&*()_+{}|:"<>?qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM`;
44
+ const VALID_KEYS = `\`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:"<>?qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM`;
45
45
 
46
46
  export default {
47
- emits: ['optionsLoaded', 'createItem'],
47
+ emits: ['optionsLoaded', 'createItem', 'update:modelValue'],
48
48
 
49
49
  props: [
50
50
  'modelValue',
@@ -72,7 +72,6 @@ export default {
72
72
  return {
73
73
  isLoaded: false,
74
74
  resolvedOptions: [],
75
- decoratedOptions: [],
76
75
  isSearching: false,
77
76
  searchText: '',
78
77
  selectedOption: null,
@@ -84,6 +83,10 @@ export default {
84
83
  },
85
84
 
86
85
  computed: {
86
+ hasManualOptionsObject() {
87
+ return this.options && typeof this.options === 'object' && !Array.isArray(this.options);
88
+ },
89
+
87
90
  effectiveDisabled() {
88
91
  return this.disabled || !this.resolvedOptions;
89
92
  },
@@ -143,34 +146,27 @@ export default {
143
146
  return this.titleKey || 'name';
144
147
  },
145
148
 
146
- effectiveNoResultsText() {
147
- return this.noResultsText || 'No options match your search.';
148
- }
149
- },
150
-
151
- watch: {
152
- // props
153
-
154
- modelValue() {
155
- this.handleValueChanged();
156
- },
157
-
158
- options() {
159
- this.resolvedOptions = this.options;
149
+ effectiveValueKey() {
150
+ if (this.valueKey) return this.valueKey;
151
+ if (this.hasManualOptionsObject) return this.effectiveIdKey;
152
+ return undefined;
160
153
  },
161
154
 
162
- url() {
163
- this.handleSourceUpdate();
155
+ effectiveNoResultsText() {
156
+ return this.noResultsText || 'No options match your search.';
164
157
  },
165
158
 
166
- urlParams() {
167
- this.handleSourceUpdate();
159
+ resolvedOptionsArray() {
160
+ return this.hasManualOptionsObject
161
+ ? Object.entries(this.resolvedOptions).map(entry => ({
162
+ [this.effectiveIdKey]: entry[0],
163
+ [this.effectiveTitleKey]: entry[1]
164
+ }))
165
+ : this.resolvedOptions;
168
166
  },
169
167
 
170
- // data
171
-
172
- resolvedOptions() {
173
- this.decoratedOptions = this.resolvedOptions.map((option, index) => {
168
+ decoratedOptions() {
169
+ return this.resolvedOptionsArray.map((option, index) => {
174
170
  const title = this.getOptionTitle(option);
175
171
  const subtitle = this.getOptionSubtitle(option);
176
172
  const strippedTitle = title ? title.text.trim().toLowerCase() : '';
@@ -194,7 +190,31 @@ export default {
194
190
  ref: option
195
191
  };
196
192
  });
193
+ }
194
+ },
195
+
196
+ watch: {
197
+ // props
198
+
199
+ modelValue() {
200
+ this.handleValueChanged();
201
+ },
202
+
203
+ options() {
204
+ this.resolvedOptions = this.options;
205
+ },
206
+
207
+ url() {
208
+ this.handleSourceUpdate();
209
+ },
210
+
211
+ urlParams() {
212
+ this.handleSourceUpdate();
213
+ },
214
+
215
+ // data
197
216
 
217
+ decoratedOptions() {
198
218
  this.shouldDisplayOptions && setTimeout(this.highlightInitialOption, 0);
199
219
  },
200
220
 
@@ -226,6 +246,7 @@ export default {
226
246
 
227
247
  if (this.options) {
228
248
  this.resolvedOptions = this.options;
249
+ // this.buildDecoratedOptions();
229
250
  this.isLoaded = true;
230
251
  } else if (this.$isPropTruthy(this.preload)) {
231
252
  this.performInitialLoad();
@@ -235,7 +256,7 @@ export default {
235
256
 
236
257
  this.$watch('selectedOption', () => {
237
258
  const newValue =
238
- this.selectedOption && this.valueKey ? this.selectedOption[this.valueKey] : this.selectedOption;
259
+ this.selectedOption && this.effectiveValueKey ? this.selectedOption[this.effectiveValueKey] : this.selectedOption;
239
260
  newValue === this.modelValue || this.$emit('update:modelValue', newValue);
240
261
  });
241
262
  },
@@ -429,10 +450,10 @@ export default {
429
450
  this.selectedOptionTitle = null;
430
451
  this.$emit('createItem', createText);
431
452
  } else {
432
- const optionIndex = this.decoratedOptions.findIndex(
453
+ const selectedDecoratedOption = this.decoratedOptions.find(
433
454
  decoratedOption => decoratedOption.key == option.key
434
455
  );
435
- const realOption = this.resolvedOptions[optionIndex];
456
+ const realOption = selectedDecoratedOption.ref;
436
457
  this.selectedOption = realOption;
437
458
  this.selectedOptionTitle = this.getOptionTitle(this.selectedOption).text;
438
459
  this.searchText = this.selectedOptionTitle || '';
@@ -443,9 +464,9 @@ export default {
443
464
 
444
465
  handleValueChanged() {
445
466
  if (this.modelValue) {
446
- if (this.valueKey) {
447
- this.selectedOption = this.resolvedOptions.find(
448
- option => option[this.valueKey] === this.modelValue
467
+ if (this.effectiveValueKey) {
468
+ this.selectedOption = this.resolvedOptionsArray.find(
469
+ option => option[this.effectiveValueKey] === this.modelValue
449
470
  );
450
471
  } else {
451
472
  this.selectedOption = this.modelValue;