@mozaic-ds/vue 0.22.1 → 0.23.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": "@mozaic-ds/vue",
3
- "version": "0.22.1",
3
+ "version": "0.23.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -23,9 +23,9 @@
23
23
  "postinstall.js"
24
24
  ],
25
25
  "dependencies": {
26
- "@mozaic-ds/css-dev-tools": "^1.38.0",
27
- "@mozaic-ds/icons": "1.40.0",
28
- "@mozaic-ds/styles": "^1.39.1",
26
+ "@mozaic-ds/css-dev-tools": "1.38.0",
27
+ "@mozaic-ds/icons": "1.41.0",
28
+ "@mozaic-ds/styles": "1.41.0",
29
29
  "@mozaic-ds/web-fonts": "1.22.0",
30
30
  "core-js": "^3.18.3",
31
31
  "libphonenumber-js": "1.9.50",
@@ -7,7 +7,7 @@
7
7
  :style="tagStyle"
8
8
  >
9
9
  <m-tag
10
- v-if="multiple && tagValue.length > 1"
10
+ v-if="multiple && tagValue.length > 0"
11
11
  type="removable"
12
12
  :label="tagValue.length.toString() + ' ' + tagLabel"
13
13
  class="mc-autocomplete__tag"
@@ -128,8 +128,6 @@ export default {
128
128
  data() {
129
129
  return {
130
130
  itemListForDropdown: this.items,
131
- selected: this.items,
132
- itemDisplayed: '',
133
131
  isOpen: this.open,
134
132
  tagWidth: '0px',
135
133
  maxWidth: '17.875rem',
@@ -151,17 +149,20 @@ export default {
151
149
 
152
150
  watch: {
153
151
  listboxValue: function (newValue) {
152
+ const textToDisplay = [];
154
153
  const valueExpr = this.dataValueExpr;
155
154
  const textExpr = this.dataTextExpr;
156
155
 
157
- if (newValue.length === 1) {
158
- const valueToDisplay = this.items.find(
159
- (item) => item[valueExpr] == newValue
156
+ this.tagValue = newValue;
157
+
158
+ if (newValue.length) {
159
+ const selectedItems = this.items.filter((item) =>
160
+ newValue.includes(item[valueExpr])
160
161
  );
161
- this.inputValue = valueToDisplay[textExpr];
162
- } else {
163
- this.inputValue = '';
164
- this.tagValue = newValue;
162
+
163
+ selectedItems.forEach((item) => textToDisplay.push(item[textExpr]));
164
+
165
+ this.inputValue = textToDisplay.join(', ');
165
166
  }
166
167
  },
167
168
 
@@ -196,6 +197,7 @@ export default {
196
197
 
197
198
  clearAutocomplete() {
198
199
  this.listboxValue = [];
200
+ this.inputValue = '';
199
201
  this.onChange();
200
202
  this.$emit('clear');
201
203
  },
@@ -219,6 +221,10 @@ export default {
219
221
 
220
222
  onChange() {
221
223
  this.$emit('change', this.listboxValue);
224
+
225
+ if (!this.multiple) {
226
+ this.onClickOutside();
227
+ }
222
228
  },
223
229
  },
224
230
  };
@@ -231,9 +237,20 @@ export default {
231
237
 
232
238
  .mc-autocomplete {
233
239
  max-width: var(--max-width);
240
+
241
+ &__tag {
242
+ position: absolute;
243
+ top: 0;
244
+ -webkit-transform: translateY(50%);
245
+ -ms-transform: translateY(50%);
246
+ transform: translateY(50%);
247
+ }
234
248
  }
235
249
 
236
250
  .mc-autocomplete--multi .mc-autocomplete__trigger {
251
+ overflow: hidden;
237
252
  padding-left: calc(2.9375rem + var(--tag-width));
253
+ text-overflow: ellipsis;
254
+ white-space: nowrap;
238
255
  }
239
256
  </style>
@@ -25,6 +25,7 @@ export default {
25
25
  viewbox: null,
26
26
  size: null,
27
27
  paths: null,
28
+ type: null,
28
29
  };
29
30
  },
30
31
 
@@ -79,8 +80,17 @@ export default {
79
80
  this.viewbox = selectedIcon.viewBox;
80
81
  this.size = selectedIcon.size;
81
82
  this.paths = selectedIcon.paths;
83
+ this.type = selectedIcon.type;
82
84
  });
83
85
  },
86
+ setSizeFromViewbox(viewbox) {
87
+ const viewboxSizes = viewbox.split(' ').filter((size) => size > 0);
88
+
89
+ return {
90
+ width: `${viewboxSizes[0]}px`,
91
+ height: `${viewboxSizes[1]}px`,
92
+ };
93
+ },
84
94
  },
85
95
 
86
96
  render: function (createElement) {
@@ -88,8 +98,14 @@ export default {
88
98
  const svgAttrs = {
89
99
  id: `MIcon-${this.name}-${this.id}`,
90
100
  viewBox: this.viewbox,
91
- height: this.size,
92
- width: this.size,
101
+ height:
102
+ this.type !== 'logotypes'
103
+ ? this.size
104
+ : this.setSizeFromViewbox(this.viewbox).height,
105
+ width:
106
+ this.type !== 'logotypes'
107
+ ? this.size
108
+ : this.setSizeFromViewbox(this.viewbox).width,
93
109
  fill: this.color,
94
110
  'aria-hidden': 'true',
95
111
  };
@@ -146,7 +146,7 @@ export default {
146
146
  }),
147
147
  computed: {
148
148
  hasValue() {
149
- return this.phoneNumber !== '';
149
+ return this.value !== '';
150
150
  },
151
151
  placeholder() {
152
152
  return getExampleNumber(
@@ -162,6 +162,9 @@ export default {
162
162
  },
163
163
  created() {
164
164
  this.init();
165
+ if (!this.hasValue) {
166
+ this.selectedCountry = this.countries[0];
167
+ }
165
168
  },
166
169
  methods: {
167
170
  init() {
@@ -185,7 +188,6 @@ export default {
185
188
  : this.selectedCountry;
186
189
  }
187
190
  } else {
188
- this.selectedCountry = this.countries[0];
189
191
  this.phoneNumber = '';
190
192
  }
191
193
  },