@mozaic-ds/vue 0.23.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",
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": {
@@ -27,29 +27,29 @@
27
27
  "@mozaic-ds/icons": "1.41.0",
28
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,6 +1,5 @@
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 }"
@@ -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',
@@ -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 };
@@ -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';
@@ -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>
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';
package/types/index.d.ts CHANGED
@@ -16,6 +16,7 @@ declare module '@mozaic-ds/vue' {
16
16
  const MCard: VueConstructor;
17
17
  const MCheckbox: VueConstructor;
18
18
  const MCheckboxGroup: VueConstructor;
19
+ const MDropdown: VueConstructor;
19
20
  const MField: VueConstructor;
20
21
  const MFileUploader: VueConstructor;
21
22
  const MFlag: VueConstructor;
@@ -64,6 +65,7 @@ declare module '@mozaic-ds/vue' {
64
65
  MCard,
65
66
  MCheckbox,
66
67
  MCheckboxGroup,
68
+ MDropdown,
67
69
  MField,
68
70
  MFileUploader,
69
71
  MFlag,