@mozaic-ds/vue 0.34.1 → 0.35.0-beta.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.34.1",
3
+ "version": "0.35.0-beta.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -25,15 +25,15 @@
25
25
  "dependencies": {
26
26
  "@mozaic-ds/css-dev-tools": "1.50.0",
27
27
  "@mozaic-ds/icons": "1.49.0",
28
- "@mozaic-ds/styles": "1.50.0",
28
+ "@mozaic-ds/styles": "1.51.0",
29
29
  "@mozaic-ds/web-fonts": "1.22.0",
30
- "core-js": "^3.26.1",
30
+ "core-js": "^3.27.0",
31
31
  "libphonenumber-js": "^1.10.15",
32
32
  "vue": "^2.6.14",
33
33
  "vue-country-flag": "2.3.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@babel/core": "^7.20.5",
36
+ "@babel/core": "^7.20.7",
37
37
  "@babel/eslint-parser": "^7.19.1",
38
38
  "@rushstack/eslint-patch": "^1.2.0",
39
39
  "@vue/cli-plugin-babel": "~5.0.8",
@@ -41,14 +41,14 @@
41
41
  "@vue/compiler-sfc": "^3.2.45",
42
42
  "@vue/eslint-config-prettier": "^7.0.0",
43
43
  "babel-eslint": "^10.1.0",
44
- "eslint": "^8.29.0",
44
+ "eslint": "^8.30.0",
45
45
  "eslint-config-prettier": "^8.5.0",
46
46
  "eslint-plugin-vue": "^9.8.0",
47
- "postcss": "^8.4.19",
47
+ "postcss": "^8.4.20",
48
48
  "postcss-loader": "^7.0.2",
49
49
  "postcss-scss": "^4.0.6",
50
50
  "prettier": "^2.8.1",
51
- "sass": "^1.56.2",
51
+ "sass": "^1.57.1",
52
52
  "sass-loader": "^13.2.0",
53
53
  "vue-template-compiler": "^2.7.14"
54
54
  },
@@ -2,7 +2,7 @@
2
2
  <div
3
3
  v-click-outside="closeListBox"
4
4
  class="mc-autocomplete"
5
- :class="{ 'mc-autocomplete--multi': multiple }"
5
+ :class="classObject"
6
6
  :style="setStyles"
7
7
  >
8
8
  <div class="mc-autocomplete__main">
@@ -17,7 +17,6 @@
17
17
  size="s"
18
18
  @remove-tag="clearListbox()"
19
19
  />
20
- <MLoader v-if="loading" class="mc-autocomplete__loader" size="s" />
21
20
  <MTextInput
22
21
  :id="id"
23
22
  v-model="inputValue"
@@ -25,6 +24,7 @@
25
24
  :is-invalid="invalid"
26
25
  :disabled="disabled"
27
26
  :size="size"
27
+ :root-class="{ 'is-invalid': invalid }"
28
28
  text-input-field-class="mc-autocomplete__trigger"
29
29
  icon-position="left"
30
30
  icon="DisplaySearch48"
@@ -32,6 +32,7 @@
32
32
  @input="onInput"
33
33
  @click="openState = true"
34
34
  />
35
+ <MLoader v-if="loading" class="mc-autocomplete__loader" size="s" />
35
36
  <button
36
37
  v-if="hasValues"
37
38
  type="button"
@@ -211,6 +212,12 @@ export default {
211
212
  },
212
213
 
213
214
  computed: {
215
+ classObject() {
216
+ return {
217
+ 'mc-autocomplete--multi': this.multiple,
218
+ 'mc-autocomplete--clearable': this.hasValues,
219
+ };
220
+ },
214
221
  setStyles() {
215
222
  return {
216
223
  '--autocomplete-tag-width': this.tagWidth,
@@ -248,18 +255,20 @@ export default {
248
255
  },
249
256
  immediate: true,
250
257
  },
251
- listboxValue: function (val) {
252
- if (!this.multiple) {
253
- const selectedItems = this.getSelectedItems(val);
254
- const seletedLabels = selectedItems.map(
255
- (item) => item[this.dataTextExpr]
256
- );
258
+ listboxValue: {
259
+ handler: function (val) {
260
+ if (!this.multiple) {
261
+ const selectedItems = this.getSelectedItems(val);
262
+ const seletedLabels = selectedItems.map(
263
+ (item) => item[this.dataTextExpr]
264
+ );
257
265
 
258
- this.inputValue = seletedLabels.join(', ');
259
- this.$emit('update:input', this.inputValue);
260
- } else {
261
- this.tagValue = val;
262
- }
266
+ this.inputValue = seletedLabels.join(', ');
267
+ } else {
268
+ this.tagValue = val;
269
+ }
270
+ },
271
+ immediate: true,
263
272
  },
264
273
  tagValue: function () {
265
274
  this.setTagWidth();
@@ -9,7 +9,7 @@
9
9
  ref="trigger"
10
10
  type="button"
11
11
  class="mc-listbox-options__trigger"
12
- @click="onClickTrigger"
12
+ @click="onSwitch($event)"
13
13
  >
14
14
  <m-icon name="DisplayOptions24" :color="triggerIconColor" />
15
15
  <span class="mc-listbox-options__trigger-label">{{ triggerLabel }}</span>
@@ -17,7 +17,11 @@
17
17
  <div
18
18
  ref="listbox"
19
19
  class="mc-listbox-options__container"
20
- :class="{ 'is-open': isOpen, 'align-right': position == 'right' }"
20
+ :class="{
21
+ 'is-open': isOpen,
22
+ 'align-right': position == 'right',
23
+ 'align-top': displayTop,
24
+ }"
21
25
  role="listbox"
22
26
  aria-labelledby="listbox"
23
27
  >
@@ -107,6 +111,7 @@ export default {
107
111
  data() {
108
112
  return {
109
113
  isOpen: this.open,
114
+ displayTop: false,
110
115
  posTop: '0px',
111
116
  hasDataTable: false,
112
117
  };
@@ -154,21 +159,26 @@ export default {
154
159
  onClickOutside() {
155
160
  this.isOpen = false;
156
161
  },
162
+ onSwitch(e) {
163
+ if (!this.isOpen) {
164
+ if (this.$refs.listbox.clientHeight + e.clientY >= window.innerHeight) {
165
+ this.displayTop = true;
166
+ }
167
+
168
+ if (this.hasDataTable) {
169
+ const buttonSizes = this.$refs.trigger.getBoundingClientRect();
170
+ this.posTop = buttonSizes.top + buttonSizes.height;
171
+ }
172
+ }
173
+ this.isOpen = !this.isOpen;
174
+ },
157
175
  onClickItem(item, listIndex, itemIndex) {
158
176
  const valToEmit = Object.assign(
159
177
  { listIndex: listIndex, itemIndex: itemIndex },
160
178
  item
161
179
  );
162
- this.$emit('update:itemSelected', valToEmit);
163
- },
164
- onClickTrigger() {
165
- this.isOpen = !this.isOpen;
166
-
167
- if (this.isOpen && this.hasDataTable) {
168
- const buttonHeight = this.$refs.trigger.getBoundingClientRect().height;
169
- this.posTop =
170
- this.$refs.trigger.getBoundingClientRect().top + buttonHeight;
171
- }
180
+ this.$emit('update:itemSelected', valToEmit); // TODO: deprecated
181
+ this.$emit('item-clicked', valToEmit);
172
182
  },
173
183
  handleScroll() {
174
184
  this.isOpen = false;
@@ -218,8 +228,16 @@ export default {
218
228
  z-index: 11;
219
229
  }
220
230
 
231
+ &.align-top {
232
+ transform: translate(0, calc(-100% - #{$mu150}));
233
+ }
234
+
221
235
  &.align-right {
222
- transform: translateX(calc(-100% + #{$mu150}));
236
+ transform: translate(calc(-100% + #{$mu150}), 0);
237
+
238
+ &.align-top {
239
+ transform: translate(calc(-100% + #{$mu150}), calc(-100% - #{$mu150}));
240
+ }
223
241
  }
224
242
  }
225
243
 
@@ -3,7 +3,7 @@
3
3
  v-if="icon"
4
4
  key="icon-input"
5
5
  class="mc-left-icon-input"
6
- :class="cssFieldElementClass"
6
+ :class="[cssFieldElementClass, rootClass]"
7
7
  >
8
8
  <m-text-input-icon :icon="icon" />
9
9
  <m-text-input-field
@@ -49,6 +49,10 @@ export default {
49
49
  type: String,
50
50
  default: null,
51
51
  },
52
+ rootClass: {
53
+ type: String,
54
+ default: null,
55
+ },
52
56
  textInputFieldClass: {
53
57
  type: String,
54
58
  default: null,