@mozaic-ds/vue 0.35.0-beta.0 → 0.35.0-beta.1

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": "@mozaic-ds/vue",
3
- "version": "0.35.0-beta.0",
3
+ "version": "0.35.0-beta.1",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -21,10 +21,10 @@
21
21
  :id="id"
22
22
  v-model="inputValue"
23
23
  :placeholder="placeholder"
24
- :is-invalid="invalid"
24
+ :is-invalid="isInvalid"
25
25
  :disabled="disabled"
26
26
  :size="size"
27
- :root-class="{ 'is-invalid': invalid }"
27
+ :root-class="getInvalidRootClass"
28
28
  text-input-field-class="mc-autocomplete__trigger"
29
29
  icon-position="left"
30
30
  icon="DisplaySearch48"
@@ -44,6 +44,7 @@
44
44
  </button>
45
45
  </div>
46
46
  <MListBox
47
+ v-if="!isFiltered"
47
48
  v-model="listboxValue"
48
49
  :open="openState"
49
50
  :items="localItems"
@@ -52,7 +53,6 @@
52
53
  :data-key-expr="dataKeyExpr"
53
54
  :data-text-expr="dataTextExpr"
54
55
  :data-value-expr="dataValueExpr"
55
- :is-filtered="isFiltered"
56
56
  :max-width="maxWidth"
57
57
  @change="onChangeListbox"
58
58
  >
@@ -60,6 +60,9 @@
60
60
  <slot name="item" :item="item"></slot>
61
61
  </template>
62
62
  </MListBox>
63
+ <div v-else class="mc-autocomplete__error">
64
+ {{ emptySearchLabel }}
65
+ </div>
63
66
  </div>
64
67
  </template>
65
68
 
@@ -230,6 +233,13 @@ export default {
230
233
  hasValues() {
231
234
  return this.inputValue?.length > 0;
232
235
  },
236
+ isInvalid() {
237
+ return this.invalid || this.isFiltered;
238
+ },
239
+ getInvalidRootClass() {
240
+ const invalidClass = this.isInvalid ? 'is-invalid' : '';
241
+ return invalidClass;
242
+ },
233
243
  },
234
244
 
235
245
  watch: {
@@ -239,6 +249,13 @@ export default {
239
249
  },
240
250
  immediate: true,
241
251
  },
252
+ localItems: {
253
+ handler: function (val) {
254
+ // this.localItems = val;
255
+ this.isFiltered = !val.length;
256
+ this.$emit('list-filtered', val);
257
+ },
258
+ },
242
259
  input: {
243
260
  handler: function (val) {
244
261
  this.inputValue = val;
@@ -309,18 +326,24 @@ export default {
309
326
  filterList(value) {
310
327
  if (value.length && this.filter) {
311
328
  this.filter(value);
312
- } else if (value.length && this.filterOnType) {
313
- this.localItems = this.items.filter((item) =>
314
- item[this.dataTextExpr].toUpperCase().includes(value.toUpperCase())
315
- );
316
-
317
- this.isFiltered = !this.localItems.length;
318
329
  } else {
319
- this.localItems = this.items;
320
- this.isFiltered = !this.localItems.length;
321
- }
330
+ if (!this.filterOnType) {
331
+ return;
332
+ }
322
333
 
323
- this.$emit('list-filtered', this.localItems);
334
+ if (value.length) {
335
+ this.localItems = this.items.filter((item) =>
336
+ item[this.dataTextExpr].toUpperCase().includes(value.toUpperCase())
337
+ );
338
+
339
+ // this.isFiltered = !this.localItems.length;
340
+ } else {
341
+ this.localItems = this.items;
342
+ // this.isFiltered = !this.localItems.length;
343
+ }
344
+
345
+ // this.$emit('list-filtered', this.localItems);
346
+ }
324
347
  },
325
348
  closeListBox() {
326
349
  this.openState = false;
@@ -384,6 +407,18 @@ export default {
384
407
  @import 'components/c.autocomplete';
385
408
 
386
409
  .mc-autocomplete {
410
+ &__main {
411
+ position: relative;
412
+ }
413
+
414
+ &__error {
415
+ @include set-font-scale('04', 'm');
416
+
417
+ color: $color-fields-error;
418
+ display: inline-block;
419
+ margin-top: $mu025;
420
+ }
421
+
387
422
  .mc-autocomplete__trigger {
388
423
  padding-right: $mu300;
389
424
  }
@@ -6,37 +6,32 @@
6
6
  :class="{ 'is-open': open, 'mc-listbox--multi': multiple }"
7
7
  :style="{ '--listbox-width': maxWidth }"
8
8
  >
9
- <template v-if="!isFiltered">
10
- <li
11
- v-for="(item, index) in localItems"
12
- :key="item.id"
13
- class="mc-listbox__item"
14
- >
15
- <MIcon
16
- v-if="item.icon"
17
- :name="item.icon"
18
- class="mc-listbox__icon"
19
- color="#666666"
20
- />
21
- <input
22
- :id="setItemId(index)"
23
- v-model="localValue"
24
- class="mc-listbox__input"
25
- :class="{ 'mc-checkbox__input': multiple }"
26
- :type="multiple ? 'checkbox' : 'radio'"
27
- :value="item[dataValueExpr]"
28
- :name="!multiple ? `listboxradio-${uuid}` : null"
29
- @change="onChange"
30
- />
31
- <label :for="setItemId(index)" class="mc-listbox__label">
32
- <slot name="item" :item="item">
33
- {{ item[dataTextExpr] }}
34
- </slot>
35
- </label>
36
- </li>
37
- </template>
38
- <li v-else class="mc-listbox__item">
39
- <span class="mc-listbox__empty">{{ emptySearchLabel }}</span>
9
+ <li
10
+ v-for="(item, index) in localItems"
11
+ :key="item.id"
12
+ class="mc-listbox__item"
13
+ >
14
+ <MIcon
15
+ v-if="item.icon"
16
+ :name="item.icon"
17
+ class="mc-listbox__icon"
18
+ color="#666666"
19
+ />
20
+ <input
21
+ :id="setItemId(index)"
22
+ v-model="localValue"
23
+ class="mc-listbox__input"
24
+ :class="{ 'mc-checkbox__input': multiple }"
25
+ :type="multiple ? 'checkbox' : 'radio'"
26
+ :value="item[dataValueExpr]"
27
+ :name="!multiple ? `listboxradio-${uuid}` : null"
28
+ @change="onChange"
29
+ />
30
+ <label :for="setItemId(index)" class="mc-listbox__label">
31
+ <slot name="item" :item="item">
32
+ {{ item[dataTextExpr] }}
33
+ </slot>
34
+ </label>
40
35
  </li>
41
36
  </ul>
42
37
  </template>
@@ -64,18 +59,10 @@ export default {
64
59
  type: Boolean,
65
60
  default: false,
66
61
  },
67
- isFiltered: {
68
- type: Boolean,
69
- default: false,
70
- },
71
62
  multiple: {
72
63
  type: Boolean,
73
64
  default: false,
74
65
  },
75
- emptySearchLabel: {
76
- type: String,
77
- default: 'No item matching your criteria found',
78
- },
79
66
  dataKeyExpr: {
80
67
  type: String,
81
68
  default: 'id',