@mozaic-ds/vue 0.23.0-beta.0 → 0.24.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.23.0-beta.0",
3
+ "version": "0.24.0-beta.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -23,33 +23,33 @@
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
- "core-js": "^3.18.3",
31
- "libphonenumber-js": "1.9.50",
32
- "postcss-scss": "^4.0.1",
30
+ "core-js": "^3.25.0",
31
+ "libphonenumber-js": "^1.10.13",
32
+ "postcss-scss": "^4.0.4",
33
33
  "vue": "^2.6.14",
34
34
  "vue-country-flag": "2.3.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "^7.15.8",
38
- "@babel/eslint-parser": "^7.15.8",
37
+ "@babel/core": "^7.18.13",
38
+ "@babel/eslint-parser": "^7.18.9",
39
39
  "@vue/cli-plugin-babel": "~5.0.4",
40
40
  "@vue/cli-service": "~5.0.4",
41
41
  "@vue/compiler-sfc": "^3.2.20",
42
42
  "@vue/eslint-config-prettier": "^6.0.0",
43
43
  "babel-eslint": "^10.1.0",
44
- "eslint": "^7.30.0",
45
- "eslint-config-prettier": "^8.3.0",
46
- "eslint-plugin-vue": "^7.19.1",
47
- "postcss": "^8.3.9",
44
+ "eslint": "^8.23.0",
45
+ "eslint-config-prettier": "^8.5.0",
46
+ "eslint-plugin-vue": "^9.4.0",
47
+ "postcss": "^8.4.16",
48
48
  "postcss-loader": "^4.3.0",
49
- "prettier": "^2.4.1",
50
- "sass": "^1.42.1",
49
+ "prettier": "^2.7.1",
50
+ "sass": "^1.54.7",
51
51
  "sass-loader": "^10.2.0",
52
- "vue-template-compiler": "^2.6.14"
52
+ "vue-template-compiler": "^2.7.10"
53
53
  },
54
54
  "bugs": {
55
55
  "url": "https://github.com/adeo/mozaic-vue/issues"
@@ -1,13 +1,12 @@
1
1
  <template>
2
2
  <div
3
- ref="autocomplete"
4
3
  v-click-outside="onClickOutside"
5
4
  class="mc-autocomplete"
6
5
  :class="{ 'mc-autocomplete--multi': multiple }"
7
6
  :style="tagStyle"
8
7
  >
9
8
  <m-tag
10
- v-if="multiple && tagValue.length > 1"
9
+ v-if="multiple && tagValue.length > 0"
11
10
  type="removable"
12
11
  :label="tagValue.length.toString() + ' ' + tagLabel"
13
12
  class="mc-autocomplete__tag"
@@ -44,9 +43,9 @@
44
43
  </template>
45
44
 
46
45
  <script>
47
- import MListBox from '../listbox/MListBox.vue';
48
46
  import MTag from '../tags/MTag.vue';
49
47
  import MTextInput from '../textinput/MTextInput.vue';
48
+ import MListBox from '../listbox/MListBox.vue';
50
49
 
51
50
  export default {
52
51
  name: 'MAutocomplete',
@@ -128,8 +127,6 @@ export default {
128
127
  data() {
129
128
  return {
130
129
  itemListForDropdown: this.items,
131
- selected: this.items,
132
- itemDisplayed: '',
133
130
  isOpen: this.open,
134
131
  tagWidth: '0px',
135
132
  maxWidth: '17.875rem',
@@ -151,17 +148,20 @@ export default {
151
148
 
152
149
  watch: {
153
150
  listboxValue: function (newValue) {
151
+ const textToDisplay = [];
154
152
  const valueExpr = this.dataValueExpr;
155
153
  const textExpr = this.dataTextExpr;
156
154
 
157
- if (newValue.length === 1) {
158
- const valueToDisplay = this.items.find(
159
- (item) => item[valueExpr] == newValue
155
+ this.tagValue = newValue;
156
+
157
+ if (newValue.length) {
158
+ const selectedItems = this.items.filter((item) =>
159
+ newValue.includes(item[valueExpr])
160
160
  );
161
- this.inputValue = valueToDisplay[textExpr];
162
- } else {
163
- this.inputValue = '';
164
- this.tagValue = newValue;
161
+
162
+ selectedItems.forEach((item) => textToDisplay.push(item[textExpr]));
163
+
164
+ this.inputValue = textToDisplay.join(', ');
165
165
  }
166
166
  },
167
167
 
@@ -196,6 +196,7 @@ export default {
196
196
 
197
197
  clearAutocomplete() {
198
198
  this.listboxValue = [];
199
+ this.inputValue = '';
199
200
  this.onChange();
200
201
  this.$emit('clear');
201
202
  },
@@ -219,6 +220,10 @@ export default {
219
220
 
220
221
  onChange() {
221
222
  this.$emit('change', this.listboxValue);
223
+
224
+ if (!this.multiple) {
225
+ this.onClickOutside();
226
+ }
222
227
  },
223
228
  },
224
229
  };
@@ -231,9 +236,20 @@ export default {
231
236
 
232
237
  .mc-autocomplete {
233
238
  max-width: var(--max-width);
239
+
240
+ &__tag {
241
+ position: absolute;
242
+ top: 0;
243
+ -webkit-transform: translateY(50%);
244
+ -ms-transform: translateY(50%);
245
+ transform: translateY(50%);
246
+ }
234
247
  }
235
248
 
236
249
  .mc-autocomplete--multi .mc-autocomplete__trigger {
250
+ overflow: hidden;
237
251
  padding-left: calc(2.9375rem + var(--tag-width));
252
+ text-overflow: ellipsis;
253
+ white-space: nowrap;
238
254
  }
239
255
  </style>
@@ -0,0 +1,245 @@
1
+ <template>
2
+ <div
3
+ ref="dropdown"
4
+ v-click-outside="onClickOutside"
5
+ class="mc-dropdown"
6
+ :class="{ 'mc-dropdown--multi': multiple }"
7
+ :style="tagStyle"
8
+ >
9
+ <m-tag
10
+ v-if="multiple && tagValue.length > 0"
11
+ type="removable"
12
+ :label="tagValue.length.toString() + ' ' + tagLabel"
13
+ class="mc-dropdown__tag"
14
+ size="s"
15
+ @remove-tag="clearAutocomplete()"
16
+ />
17
+
18
+ <button
19
+ type="button"
20
+ class="mc-select mc-dropdown__trigger"
21
+ :class="{ 'is-open': isOpen }"
22
+ @click="isOpen = !isOpen"
23
+ >
24
+ {{ inputValue }}
25
+ </button>
26
+ <m-list-box
27
+ v-model="listboxValue"
28
+ :open="isOpen"
29
+ :items="itemListForDropdown"
30
+ :multiple="multiple"
31
+ :data-key-expr="dataKeyExpr"
32
+ :data-text-expr="dataTextExpr"
33
+ :data-value-expr="dataValueExpr"
34
+ @change="onChange"
35
+ >
36
+ <template #item="{ item }">
37
+ <slot name="item" :item="item" />
38
+ </template>
39
+ </m-list-box>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ import MListBox from '../listbox/MListBox.vue';
45
+ import MTag from '../tags/MTag.vue';
46
+
47
+ export default {
48
+ name: 'MDropdown',
49
+
50
+ components: {
51
+ MListBox,
52
+ MTag,
53
+ },
54
+
55
+ directives: {
56
+ 'click-outside': {
57
+ bind(el, binding, vnode) {
58
+ el.clickOutsideEvent = (event) => {
59
+ if (!(el === event.target || el.contains(event.target))) {
60
+ vnode.context[binding.expression](event);
61
+ }
62
+ };
63
+ document.body.addEventListener('click', el.clickOutsideEvent);
64
+ },
65
+ unbind(el) {
66
+ document.body.removeEventListener('click', el.clickOutsideEvent);
67
+ },
68
+ },
69
+ },
70
+
71
+ model: {
72
+ event: 'change',
73
+ },
74
+
75
+ props: {
76
+ open: {
77
+ type: Boolean,
78
+ default: false,
79
+ },
80
+ tagLabel: {
81
+ type: String,
82
+ default: '',
83
+ },
84
+ placeholder: {
85
+ type: String,
86
+ default: '-- Placeholder --',
87
+ },
88
+ items: {
89
+ type: Array,
90
+ default: () => [],
91
+ required: true,
92
+ },
93
+ multiple: {
94
+ type: Boolean,
95
+ default: false,
96
+ },
97
+ disabled: {
98
+ type: Boolean,
99
+ default: false,
100
+ },
101
+ dataKeyExpr: {
102
+ type: String,
103
+ default: 'id',
104
+ },
105
+ dataTextExpr: {
106
+ type: String,
107
+ default: 'label',
108
+ },
109
+ dataValueExpr: {
110
+ type: String,
111
+ default: 'value',
112
+ },
113
+ value: {
114
+ type: Array,
115
+ default: () => [],
116
+ },
117
+ },
118
+
119
+ data() {
120
+ return {
121
+ itemListForDropdown: this.items,
122
+ isOpen: this.open,
123
+ tagWidth: '0px',
124
+ maxWidth: '17.875rem',
125
+ uuid: undefined,
126
+ tagValue: '',
127
+ inputValue: '',
128
+ listboxValue: [],
129
+ };
130
+ },
131
+
132
+ computed: {
133
+ tagStyle() {
134
+ return {
135
+ '--tag-width': this.tagWidth,
136
+ '--max-width': this.maxWidth,
137
+ };
138
+ },
139
+ },
140
+
141
+ watch: {
142
+ listboxValue: function (newValue) {
143
+ const textToDisplay = [];
144
+ const valueExpr = this.dataValueExpr;
145
+ const textExpr = this.dataTextExpr;
146
+
147
+ this.tagValue = newValue;
148
+
149
+ if (newValue.length) {
150
+ const selectedItems = this.items.filter((item) =>
151
+ newValue.includes(item[valueExpr])
152
+ );
153
+
154
+ selectedItems.forEach((item) => textToDisplay.push(item[textExpr]));
155
+
156
+ this.inputValue = textToDisplay.join(', ');
157
+ } else {
158
+ this.inputValue = this.placeholder;
159
+ }
160
+ },
161
+
162
+ tagValue: {
163
+ handler: function () {
164
+ this.setTagWidth();
165
+ },
166
+ immediate: true,
167
+ },
168
+
169
+ value: {
170
+ handler: function (value) {
171
+ this.listboxValue = value;
172
+ },
173
+ immediate: true,
174
+ },
175
+ },
176
+
177
+ mounted() {
178
+ this.uuid = this._uid;
179
+ },
180
+
181
+ methods: {
182
+ setTagWidth() {
183
+ this.$nextTick(() => {
184
+ this.tagWidth =
185
+ document && document.querySelector('.mc-dropdown__tag')
186
+ ? document.querySelector('.mc-dropdown__tag').clientWidth + 8 + 'px'
187
+ : '0px';
188
+ });
189
+ },
190
+
191
+ clearAutocomplete() {
192
+ this.listboxValue = [];
193
+ this.inputValue = '';
194
+ this.onChange();
195
+ this.$emit('clear');
196
+ },
197
+
198
+ onClickOutside() {
199
+ this.isOpen = false;
200
+ },
201
+
202
+ onChange() {
203
+ this.$emit('change', this.listboxValue);
204
+
205
+ if (!this.multiple) {
206
+ this.onClickOutside();
207
+ }
208
+ },
209
+ },
210
+ };
211
+ </script>
212
+
213
+ <style lang="scss">
214
+ @import 'settings-tools/all-settings';
215
+ @import 'components/c.checkbox';
216
+ @import 'components/_c.dropdown';
217
+
218
+ .mc-dropdown {
219
+ max-width: var(--max-width);
220
+
221
+ &__tag {
222
+ position: absolute;
223
+ top: 0;
224
+ -webkit-transform: translateY(50%);
225
+ -ms-transform: translateY(50%);
226
+ transform: translateY(50%);
227
+ }
228
+
229
+ &__trigger {
230
+ display: block;
231
+ text-align: left;
232
+
233
+ &.is-open {
234
+ background-image: url(inline-icons('arrow-top-16', black));
235
+ }
236
+ }
237
+ }
238
+
239
+ .mc-dropdown--multi .mc-dropdown__trigger {
240
+ overflow: hidden;
241
+ padding-left: calc(0.75rem + var(--tag-width));
242
+ text-overflow: ellipsis;
243
+ white-space: nowrap;
244
+ }
245
+ </style>
@@ -0,0 +1,7 @@
1
+ import MDropdown from './MDropdown.vue';
2
+
3
+ MDropdown.install = function (Vue) {
4
+ Vue.component(MDropdown.name, MDropdown);
5
+ };
6
+
7
+ export { MDropdown };
@@ -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
  };
@@ -12,6 +12,7 @@ export { MCard } from './card';
12
12
  export { MCheckbox, MCheckboxGroup } from './checkbox';
13
13
  export { MDataTable, MDataTableHeader } from './datatable';
14
14
  export { MField } from './field';
15
+ export { MDropdown } from './dropdown';
15
16
  export { MFileUploader } from './fileuploader';
16
17
  export { MFlag } from './flag';
17
18
  export { MHero } from './hero';
@@ -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
  },
@@ -16,6 +16,7 @@
16
16
 
17
17
  <MTextInputField
18
18
  :id="id"
19
+ ref="input"
19
20
  :value="currentValue"
20
21
  type="number"
21
22
  class="mc-quantity-selector__input"
@@ -29,6 +30,7 @@
29
30
  :disabled="disabled"
30
31
  role="spinbutton"
31
32
  @input="handle"
33
+ @focus="onFocus"
32
34
  @keypress="integerOnly && formatValue($event)"
33
35
  v-on="$listeners"
34
36
  />
@@ -151,6 +153,9 @@ export default {
151
153
  e.preventDefault();
152
154
  }
153
155
  },
156
+ onFocus(e) {
157
+ e.target.select();
158
+ },
154
159
  },
155
160
  };
156
161
  </script>
@@ -18,6 +18,8 @@
18
18
  v-if="tab.router"
19
19
  v-bind="tab.attrs"
20
20
  :to="tab.to"
21
+ class="mc-tabs__link"
22
+ :class="setLinkClass(tab)"
21
23
  active-class="mc-tabs__link--selected"
22
24
  >
23
25
  {{ tab.text }}
@@ -87,7 +89,7 @@ export default {
87
89
  },
88
90
  activeIndex: {
89
91
  type: Number,
90
- default: 0,
92
+ default: null,
91
93
  },
92
94
  },
93
95
 
@@ -162,15 +164,6 @@ export default {
162
164
  tab.classList.add('mc-tabs__link--selected');
163
165
  tab.setAttribute('aria-selected', 'true');
164
166
  },
165
- setTabState(tab) {
166
- this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
167
- el.classList.remove('mc-tabs__link--selected');
168
- el.setAttribute('aria-selected', 'false');
169
- });
170
-
171
- tab.classList.add('mc-tabs__link--selected');
172
- tab.setAttribute('aria-selected', 'true');
173
- },
174
167
  getTabFromIndex: function (index) {
175
168
  if (
176
169
  this.tablist &&
@@ -185,7 +178,7 @@ export default {
185
178
  return;
186
179
  }
187
180
 
188
- if (!this.activeIndex) {
181
+ if (typeof this.activeIndex !== 'number') {
189
182
  this.localActiveIndex = index;
190
183
  }
191
184
 
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ export { MCard } from './components/card/';
31
31
  export { MCheckbox, MCheckboxGroup } from './components/checkbox/';
32
32
  export { MDataTable, MDataTableHeader } from './components/datatable';
33
33
  export { MField } from './components/field';
34
+ export { MDropdown } from './components/dropdown';
34
35
  export { MFileUploader } from './components/fileuploader';
35
36
  export { MFlag } from './components/flag';
36
37
  export { MHero } from './components/hero';