@mozaic-ds/vue 0.20.0-beta.2 → 0.20.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/dist/mozaic-vue.adeo.css +3 -3
- package/dist/mozaic-vue.adeo.umd.js +651 -17696
- package/dist/mozaic-vue.common.js +651 -17696
- package/dist/mozaic-vue.common.js.map +1 -1
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.umd.js +651 -17696
- package/dist/mozaic-vue.umd.js.map +1 -1
- package/dist/mozaic-vue.umd.min.js +2 -8
- package/dist/mozaic-vue.umd.min.js.map +1 -1
- package/package.json +3 -5
- package/src/components/autocomplete/MAutocomplete.vue +97 -129
- package/src/components/listbox/MListBox.vue +42 -85
- package/src/components/quantityselector/MQuantitySelector.vue +2 -0
- package/src/components/ratingstars/MStarsInput.vue +1 -0
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mozaic-ds/vue",
|
|
3
|
-
"version": "0.20.0
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Vue.js implementation of Mozaic Design System",
|
|
5
5
|
"author": "Adeo - Mozaic Design System",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"serve": "vue-cli-service serve",
|
|
8
8
|
"build": "vue-cli-service build ./src/index.js",
|
|
9
9
|
"lint": "vue-cli-service lint",
|
|
10
|
-
"build:bundle": "vue-cli-service build --target lib --
|
|
11
|
-
"build:bundleAdeo": "vue-cli-service build --
|
|
10
|
+
"build:bundle": "vue-cli-service build --target lib --name mozaic-vue ./src/index.js",
|
|
11
|
+
"build:bundleAdeo": "vue-cli-service build --target lib --formats umd --mode adeo --filename mozaic-vue.adeo ./src/index.js --no-clean",
|
|
12
12
|
"postinstall": "node postinstall.js",
|
|
13
13
|
"prepublishOnly": "npm run-script build:bundle && npm run-script build:bundleAdeo",
|
|
14
14
|
"publish:beta": "npm publish --access public --tag alpha",
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
"@mozaic-ds/icons": "1.34.0",
|
|
28
28
|
"@mozaic-ds/styles": "1.33.0",
|
|
29
29
|
"@mozaic-ds/web-fonts": "1.22.0",
|
|
30
|
-
"@vue/composition-api": "^1.6.2",
|
|
31
|
-
"@vueuse/core": "^8.6.0",
|
|
32
30
|
"core-js": "^3.18.3",
|
|
33
31
|
"libphonenumber-js": "1.9.50",
|
|
34
32
|
"postcss-scss": "^4.0.1",
|
|
@@ -3,41 +3,37 @@
|
|
|
3
3
|
ref="autocomplete"
|
|
4
4
|
class="mc-autocomplete"
|
|
5
5
|
:class="{ 'mc-autocomplete--multi': multiple }"
|
|
6
|
+
:style="tagStyle"
|
|
7
|
+
@keyup.esc="isOpen = true"
|
|
6
8
|
>
|
|
7
9
|
<m-tag
|
|
8
|
-
v-if="multiple &&
|
|
10
|
+
v-if="multiple && selectedItems().length > 0"
|
|
9
11
|
id="tag"
|
|
10
12
|
type="removable"
|
|
11
|
-
:label="selectedItems.length.toString() + ' ' + labelTag"
|
|
13
|
+
:label="selectedItems().length.toString() + ' ' + labelTag"
|
|
12
14
|
class="mc-autocomplete__tag"
|
|
13
15
|
size="s"
|
|
14
16
|
@remove-tag="removeElementsFromList()"
|
|
15
17
|
/>
|
|
16
18
|
<m-text-input
|
|
17
|
-
v-model="
|
|
19
|
+
v-model="itemDisplayed"
|
|
18
20
|
:placeholder="placeholder"
|
|
19
|
-
class="mc-autocomplete__trigger"
|
|
21
|
+
text-input-field-class="mc-autocomplete__trigger"
|
|
20
22
|
icon-position="left"
|
|
21
23
|
icon="DisplaySearch48"
|
|
22
24
|
autocomplete="off"
|
|
23
25
|
:style="{ width: boxWidth + 'px' }"
|
|
24
|
-
@
|
|
25
|
-
@
|
|
26
|
-
@click="state.open = true"
|
|
26
|
+
@input="filerList"
|
|
27
|
+
@click="isOpen = true"
|
|
27
28
|
/>
|
|
28
29
|
<m-list-box
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:open="state.open"
|
|
32
|
-
:items="sort ? orderedItems() : state.itemListForDropdown"
|
|
30
|
+
:open="isOpen"
|
|
31
|
+
:items="sort ? orderedItems() : itemListForDropdown"
|
|
33
32
|
:multiple="multiple"
|
|
34
33
|
:empty-search-label="emptySearchLabel"
|
|
35
34
|
:style="{ width: boxWidth + 'px' }"
|
|
36
|
-
:
|
|
37
|
-
|
|
38
|
-
:data-value-expr="dataValueExpr"
|
|
39
|
-
@update:modelValue="(selected) => updateList(selected)"
|
|
40
|
-
@close-list-box="state.open = false"
|
|
35
|
+
@update:itemSelected="updateList"
|
|
36
|
+
@close-list-box="isOpen = false"
|
|
41
37
|
>
|
|
42
38
|
<template #item="{ item }">
|
|
43
39
|
<slot name="item" :item="item"> </slot>
|
|
@@ -47,26 +43,14 @@
|
|
|
47
43
|
</template>
|
|
48
44
|
|
|
49
45
|
<script>
|
|
50
|
-
import {
|
|
51
|
-
ref,
|
|
52
|
-
reactive,
|
|
53
|
-
onMounted,
|
|
54
|
-
computed,
|
|
55
|
-
nextTick,
|
|
56
|
-
} from '@vue/composition-api';
|
|
57
|
-
import { onClickOutside } from '@vueuse/core';
|
|
58
|
-
import MListBox from '../listbox/MListBox.vue';
|
|
59
|
-
import MTag from '../tags/MTag.vue';
|
|
60
46
|
import MTextInput from '../textinput/MTextInput.vue';
|
|
47
|
+
import MTag from '../tags/MTag.vue';
|
|
48
|
+
import MListBox from '../listbox/MListBox.vue';
|
|
61
49
|
|
|
62
50
|
export default {
|
|
63
51
|
name: 'MAutocomplete',
|
|
64
52
|
|
|
65
|
-
components: {
|
|
66
|
-
MListBox,
|
|
67
|
-
MTag,
|
|
68
|
-
MTextInput,
|
|
69
|
-
},
|
|
53
|
+
components: { MListBox, MTag, MTextInput },
|
|
70
54
|
|
|
71
55
|
props: {
|
|
72
56
|
multiple: {
|
|
@@ -98,55 +82,54 @@ export default {
|
|
|
98
82
|
type: String,
|
|
99
83
|
default: '',
|
|
100
84
|
},
|
|
101
|
-
|
|
102
|
-
type:
|
|
103
|
-
default:
|
|
85
|
+
open: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
104
88
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
},
|
|
90
|
+
data() {
|
|
91
|
+
return {
|
|
92
|
+
itemListForDropdown: this.$props.items,
|
|
93
|
+
selected: this.$props.items,
|
|
94
|
+
itemDisplayed: '',
|
|
95
|
+
isOpen: this.$props.open,
|
|
96
|
+
tagWidth: '0px',
|
|
97
|
+
boxWidth: '288px',
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
tagStyle() {
|
|
102
|
+
return {
|
|
103
|
+
'--tag-width': this.tagWidth,
|
|
104
|
+
};
|
|
108
105
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
boxStyle() {
|
|
107
|
+
return {
|
|
108
|
+
'--box-width': this.boxWidth,
|
|
109
|
+
};
|
|
112
110
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
},
|
|
112
|
+
mounted() {
|
|
113
|
+
this.selectedItems();
|
|
114
|
+
this.tagWidthCalcul();
|
|
115
|
+
this.boxWidthCalcul();
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
tagWidthCalcul() {
|
|
119
|
+
this.$nextTick(() => {
|
|
120
|
+
this.tagWidth =
|
|
121
|
+
document && document.querySelector('.mc-autocomplete__tag')
|
|
122
|
+
? document.querySelector('.mc-autocomplete__tag').clientWidth + 'px'
|
|
123
|
+
: '0px';
|
|
124
|
+
});
|
|
116
125
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
selectedItems() {
|
|
127
|
+
return this.selected.filter((item) => {
|
|
128
|
+
return item.selected;
|
|
129
|
+
});
|
|
120
130
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
emits: ['update:modelValue', 'list-removed', 'list-filtered', 'input-change'],
|
|
124
|
-
|
|
125
|
-
setup(props, { emit }) {
|
|
126
|
-
const autocomplete = ref(null);
|
|
127
|
-
const listbox = ref(null);
|
|
128
|
-
|
|
129
|
-
const state = reactive({
|
|
130
|
-
open: false,
|
|
131
|
-
itemListForDropdown: props.items,
|
|
132
|
-
selected: [],
|
|
133
|
-
itemDisplayed: '',
|
|
134
|
-
tagWidth: '0px',
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
onMounted(() => {
|
|
138
|
-
manageTag();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const selectedItems = computed(() =>
|
|
142
|
-
state.selected.filter((item) => {
|
|
143
|
-
return item[props.dataValueExpr];
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
const orderedItems = () => {
|
|
148
|
-
// Order by selected then by id
|
|
149
|
-
return Array.from(state.itemListForDropdown).sort((a, b) => {
|
|
131
|
+
orderedItems() {
|
|
132
|
+
this.itemListForDropdown.sort((a, b) => {
|
|
150
133
|
if (a.selected === b.selected) {
|
|
151
134
|
return a.id - b.id;
|
|
152
135
|
} else if (a.selected < b.selected) {
|
|
@@ -155,67 +138,52 @@ export default {
|
|
|
155
138
|
return -1;
|
|
156
139
|
}
|
|
157
140
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
onClickOutside(listbox, () => (state.open = false));
|
|
165
|
-
|
|
166
|
-
const updateList = (list) => {
|
|
167
|
-
if (!props.multiple && list) {
|
|
168
|
-
state.itemDisplayed = list[0].value;
|
|
141
|
+
},
|
|
142
|
+
updateList(list) {
|
|
143
|
+
if (!this.$props.multiple && list) {
|
|
144
|
+
this.itemDisplayed = list[0].text;
|
|
169
145
|
} else {
|
|
170
|
-
|
|
171
|
-
|
|
146
|
+
this.isOpen = true;
|
|
147
|
+
this.selectedItems();
|
|
172
148
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
149
|
+
this.itemListForDropdown.forEach((elem) => {
|
|
150
|
+
if (elem.id === list.id) {
|
|
151
|
+
elem.selected = false;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this.tagWidthCalcul();
|
|
155
|
+
this.$emit(
|
|
156
|
+
'update:modelValue',
|
|
157
|
+
this.$props.multiple ? this.selectedItems().value : list
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
removeElementsFromList() {
|
|
161
|
+
this.itemListForDropdown.forEach((elem) => {
|
|
162
|
+
elem.selected = false;
|
|
163
|
+
});
|
|
164
|
+
this.selectedItems();
|
|
165
|
+
this.tagWidthCalcul();
|
|
166
|
+
this.$emit('list-removed');
|
|
167
|
+
},
|
|
168
|
+
filerList(value) {
|
|
169
|
+
if (value.length && this.$props.filter) {
|
|
170
|
+
this.$props.filter(value);
|
|
187
171
|
} else if (value.length) {
|
|
188
|
-
|
|
189
|
-
item
|
|
172
|
+
this.itemListForDropdown = this.itemListForDropdown.filter((item) =>
|
|
173
|
+
item.text.toUpperCase().includes(value.toUpperCase())
|
|
190
174
|
);
|
|
191
175
|
} else {
|
|
192
|
-
|
|
176
|
+
this.itemListForDropdown = this.$props.items;
|
|
193
177
|
}
|
|
194
|
-
emit('
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
state.tagWidth =
|
|
201
|
-
document && document.querySelector('.mc-autocomplete__tag')
|
|
202
|
-
? document.querySelector('.mc-autocomplete__tag').clientWidth + 'px'
|
|
203
|
-
: '0px';
|
|
178
|
+
this.$emit('list-filtered', this.itemListForDropdown);
|
|
179
|
+
},
|
|
180
|
+
boxWidthCalcul() {
|
|
181
|
+
this.$nextTick(() => {
|
|
182
|
+
this.boxWidth = document.querySelector('.mc-autocomplete').clientWidth;
|
|
183
|
+
console.log(this.boxWidth);
|
|
204
184
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
autocomplete,
|
|
209
|
-
listbox,
|
|
210
|
-
state,
|
|
211
|
-
selectedItems,
|
|
212
|
-
orderedItems,
|
|
213
|
-
boxWidth,
|
|
214
|
-
updateList,
|
|
215
|
-
removeElementsFromList,
|
|
216
|
-
updateDropdown,
|
|
217
|
-
manageTag,
|
|
218
|
-
};
|
|
185
|
+
return;
|
|
186
|
+
},
|
|
219
187
|
},
|
|
220
188
|
};
|
|
221
189
|
</script>
|
|
@@ -1,48 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ul
|
|
3
|
-
v-if="
|
|
3
|
+
v-if="items.length > 0"
|
|
4
4
|
ref="listbox"
|
|
5
5
|
role="listbox"
|
|
6
|
-
class="mc-listbox
|
|
6
|
+
class="mc-listbox"
|
|
7
7
|
aria-labelledby="listbox"
|
|
8
|
-
:class="{ 'is-open': open }"
|
|
8
|
+
:class="{ 'is-open': open, 'mc-listbox--multi': multiple }"
|
|
9
9
|
>
|
|
10
10
|
<li
|
|
11
|
-
v-for="item in
|
|
12
|
-
:key="item
|
|
11
|
+
v-for="item in selectableItems"
|
|
12
|
+
:key="item.id"
|
|
13
13
|
class="mc-listbox__item"
|
|
14
|
+
@change="$emit('update:itemSelected', item)"
|
|
15
|
+
@click.self="updateList(item.id, item.text, !item.selected, true)"
|
|
14
16
|
>
|
|
15
17
|
<slot name="item" :item="item">
|
|
16
|
-
<
|
|
17
|
-
:for="`checkbox-dropdown-${item[dataKeyExpr]}-${uuid}`"
|
|
18
|
-
class="mc-listbox__label"
|
|
19
|
-
>{{ item[dataTextExpr] }}
|
|
20
|
-
</label>
|
|
18
|
+
<span class="mc-listbox__text">{{ item.text }} </span>
|
|
21
19
|
</slot>
|
|
22
20
|
<m-checkbox
|
|
23
|
-
|
|
24
|
-
:
|
|
21
|
+
v-if="multiple"
|
|
22
|
+
:id="`checkbox-dropdown-${item.id}`"
|
|
23
|
+
v-model="selectableItems.find((elem) => elem.id === item.id).selected"
|
|
25
24
|
class="mc-listbox__input"
|
|
26
|
-
|
|
27
|
-
@update:modelValue="(v) => updateList(v, item[dataValueExpr])"
|
|
25
|
+
@change="updateList(item.id, item.text, !item.selected, $e)"
|
|
28
26
|
/>
|
|
29
27
|
</li>
|
|
30
28
|
</ul>
|
|
31
|
-
<div v-else class="mc-
|
|
29
|
+
<div v-else class="mc-list-box__empty">
|
|
32
30
|
{{ emptySearchLabel }}
|
|
33
31
|
</div>
|
|
34
32
|
</template>
|
|
35
|
-
|
|
36
33
|
<script>
|
|
37
|
-
import { reactive, watch, ref } from '@vue/composition-api';
|
|
38
34
|
import MCheckbox from '../checkbox/MCheckbox.vue';
|
|
39
|
-
|
|
40
35
|
export default {
|
|
41
36
|
name: 'MListbox',
|
|
42
37
|
|
|
43
|
-
components: {
|
|
44
|
-
MCheckbox,
|
|
45
|
-
},
|
|
38
|
+
components: { MCheckbox },
|
|
46
39
|
|
|
47
40
|
props: {
|
|
48
41
|
open: {
|
|
@@ -65,80 +58,44 @@ export default {
|
|
|
65
58
|
type: Boolean,
|
|
66
59
|
default: false,
|
|
67
60
|
},
|
|
68
|
-
dataKeyExpr: {
|
|
69
|
-
type: String,
|
|
70
|
-
default: 'id',
|
|
71
|
-
},
|
|
72
|
-
dataTextExpr: {
|
|
73
|
-
type: String,
|
|
74
|
-
default: 'text',
|
|
75
|
-
},
|
|
76
|
-
dataValueExpr: {
|
|
77
|
-
type: String,
|
|
78
|
-
default: 'text',
|
|
79
|
-
},
|
|
80
|
-
modelValue: {
|
|
81
|
-
type: Array,
|
|
82
|
-
default: () => [],
|
|
83
|
-
},
|
|
84
61
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
setup(props, { emit }) {
|
|
89
|
-
const listbox = ref(null);
|
|
90
|
-
|
|
91
|
-
let uuid = Math.random();
|
|
92
|
-
|
|
93
|
-
const state = reactive({
|
|
94
|
-
selectableItems: props.items,
|
|
62
|
+
data() {
|
|
63
|
+
return {
|
|
64
|
+
selectableItems: null,
|
|
95
65
|
selected: [],
|
|
96
|
-
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
watch: {
|
|
69
|
+
items: {
|
|
70
|
+
handler: function (val) {
|
|
71
|
+
this.selectableItems = val;
|
|
72
|
+
},
|
|
73
|
+
immediate: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
updateList(id, text, value, isCheckboxUpdate) {
|
|
78
|
+
if (!this.multiple) {
|
|
79
|
+
this.$emit('update:itemSelected', [{ id, selected: value, text }]);
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
if (!props.multiple) {
|
|
100
|
-
emit('update:modelValue', [{ value }]);
|
|
101
|
-
emit('close-list-box');
|
|
81
|
+
this.$emit('close-list-box');
|
|
102
82
|
return;
|
|
103
83
|
}
|
|
104
84
|
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
85
|
+
if (
|
|
86
|
+
isCheckboxUpdate &&
|
|
87
|
+
this.selectableItems.find((item) => item.id === id)
|
|
88
|
+
) {
|
|
89
|
+
this.selectableItems.find((item) => item.id === id).selected = value;
|
|
111
90
|
}
|
|
112
|
-
emit('update:modelValue', state.selected);
|
|
113
|
-
};
|
|
114
91
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (state.selected) {
|
|
118
|
-
return (
|
|
119
|
-
state.selected.filter(
|
|
120
|
-
(item) => item[props.dataValueExpr] === value[props.dataValueExpr]
|
|
121
|
-
).length > 0
|
|
122
|
-
);
|
|
92
|
+
if (value) {
|
|
93
|
+
this.selected = [...this.selected, { id, selected: value, text }];
|
|
123
94
|
} else {
|
|
124
|
-
|
|
95
|
+
this.selected = this.selected.filter((item) => item.id !== id);
|
|
125
96
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
watch(
|
|
129
|
-
() => props.items,
|
|
130
|
-
(nextItems) => {
|
|
131
|
-
state.selectableItems = nextItems;
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
listbox,
|
|
137
|
-
uuid,
|
|
138
|
-
state,
|
|
139
|
-
updateList,
|
|
140
|
-
updateModelValue,
|
|
141
|
-
};
|
|
97
|
+
this.$emit('update:itemSelected', this.selectableItems);
|
|
98
|
+
},
|
|
142
99
|
},
|
|
143
100
|
};
|
|
144
101
|
</script>
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
:disabled="currentValue === valuemin"
|
|
11
11
|
:size="small ? 's' : null"
|
|
12
12
|
tabindex="-1"
|
|
13
|
+
type="button"
|
|
13
14
|
@click="decrement()"
|
|
14
15
|
/>
|
|
15
16
|
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
:disabled="currentValue === valuemax"
|
|
41
42
|
:size="small ? 's' : null"
|
|
42
43
|
tabindex="-1"
|
|
44
|
+
type="button"
|
|
43
45
|
@click="increment()"
|
|
44
46
|
/>
|
|
45
47
|
</div>
|