@mozaic-ds/vue 0.23.0 → 1.0.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.
Files changed (36) hide show
  1. package/dist/mozaic-vue.adeo.css +43 -43
  2. package/dist/mozaic-vue.adeo.umd.js +1319 -3718
  3. package/dist/mozaic-vue.common.js +1319 -3718
  4. package/dist/mozaic-vue.common.js.map +1 -1
  5. package/dist/mozaic-vue.css +1 -1
  6. package/dist/mozaic-vue.umd.js +1321 -3720
  7. package/dist/mozaic-vue.umd.js.map +1 -1
  8. package/dist/mozaic-vue.umd.min.js +2 -2
  9. package/dist/mozaic-vue.umd.min.js.map +1 -1
  10. package/package.json +4 -4
  11. package/src/components/autocomplete/MAutocomplete.vue +93 -151
  12. package/src/components/checkbox/MCheckboxGroup.vue +0 -8
  13. package/src/components/datatable/MDataTable.vue +162 -290
  14. package/src/components/datatable/MDataTableTop.vue +35 -0
  15. package/src/components/icon/MIcon.vue +2 -18
  16. package/src/components/index.js +1 -1
  17. package/src/components/listbox/MListBox.vue +41 -213
  18. package/src/components/listbox/index.js +1 -6
  19. package/src/components/phonenumber/MPhoneNumber.vue +2 -5
  20. package/src/components/quantityselector/MQuantitySelector.vue +2 -10
  21. package/src/components/ratingstars/MStarsInput.vue +0 -1
  22. package/src/components/stepper/MStepper.vue +27 -68
  23. package/src/components/tabs/MTab.vue +55 -65
  24. package/src/components/textinput/MTextInputField.vue +1 -0
  25. package/src/index.js +1 -1
  26. package/src/tokens/adeo/android/colors.xml +166 -209
  27. package/src/tokens/adeo/css/_variables.scss +166 -209
  28. package/src/tokens/adeo/css/root.scss +46 -89
  29. package/src/tokens/adeo/ios/StyleDictionaryColor.h +5 -48
  30. package/src/tokens/adeo/ios/StyleDictionaryColor.m +171 -214
  31. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +166 -209
  32. package/src/tokens/adeo/js/tokens.js +166 -209
  33. package/src/tokens/adeo/js/tokensObject.js +310 -1285
  34. package/src/tokens/adeo/scss/_tokens.scss +174 -344
  35. package/types/index.d.ts +0 -2
  36. package/src/components/listbox/MListBoxActions.vue +0 -251
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaic-ds/vue",
3
- "version": "0.23.0",
3
+ "version": "1.0.0-beta.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.41.0",
28
- "@mozaic-ds/styles": "1.41.0",
26
+ "@mozaic-ds/css-dev-tools": "2.0.0-rc.1",
27
+ "@mozaic-ds/icons": "1.34.0",
28
+ "@mozaic-ds/styles": "2.0.0-rc.4",
29
29
  "@mozaic-ds/web-fonts": "1.22.0",
30
30
  "core-js": "^3.18.3",
31
31
  "libphonenumber-js": "1.9.50",
@@ -1,103 +1,70 @@
1
1
  <template>
2
2
  <div
3
3
  ref="autocomplete"
4
- v-click-outside="onClickOutside"
5
4
  class="mc-autocomplete"
6
5
  :class="{ 'mc-autocomplete--multi': multiple }"
7
6
  :style="tagStyle"
7
+ @keyup.esc="isOpen = true"
8
8
  >
9
9
  <m-tag
10
- v-if="multiple && tagValue.length > 0"
10
+ v-if="multiple && selectedItems().length > 0"
11
+ id="tag"
11
12
  type="removable"
12
- :label="tagValue.length.toString() + ' ' + tagLabel"
13
+ :label="selectedItems().length.toString() + ' ' + labelTag"
13
14
  class="mc-autocomplete__tag"
14
15
  size="s"
15
- @remove-tag="clearAutocomplete()"
16
+ @remove-tag="removeElementsFromList()"
16
17
  />
17
18
  <m-text-input
18
- v-model="inputValue"
19
+ v-model="itemDisplayed"
19
20
  :placeholder="placeholder"
20
- :is-invalid="itemListForDropdown.length === 0"
21
21
  text-input-field-class="mc-autocomplete__trigger"
22
22
  icon-position="left"
23
23
  icon="DisplaySearch48"
24
24
  autocomplete="off"
25
- @input="filterList"
25
+ :style="{ width: boxWidth + 'px' }"
26
+ @input="filerList"
26
27
  @click="isOpen = true"
27
28
  />
28
29
  <m-list-box
29
- v-model="listboxValue"
30
30
  :open="isOpen"
31
- :items="itemListForDropdown"
31
+ :items="sort ? orderedItems() : itemListForDropdown"
32
32
  :multiple="multiple"
33
33
  :empty-search-label="emptySearchLabel"
34
- :data-key-expr="dataKeyExpr"
35
- :data-text-expr="dataTextExpr"
36
- :data-value-expr="dataValueExpr"
37
- @change="onChange"
34
+ :style="{ width: boxWidth + 'px' }"
35
+ @update:itemSelected="updateList"
36
+ @close-list-box="isOpen = false"
38
37
  >
39
38
  <template #item="{ item }">
40
- <slot name="item" :item="item" />
39
+ <slot name="item" :item="item"> </slot>
41
40
  </template>
42
41
  </m-list-box>
43
42
  </div>
44
43
  </template>
45
44
 
46
45
  <script>
47
- import MListBox from '../listbox/MListBox.vue';
48
- import MTag from '../tags/MTag.vue';
49
46
  import MTextInput from '../textinput/MTextInput.vue';
47
+ import MTag from '../tags/MTag.vue';
48
+ import MListBox from '../listbox/MListBox.vue';
50
49
 
51
50
  export default {
52
51
  name: 'MAutocomplete',
53
52
 
54
- components: {
55
- MListBox,
56
- MTag,
57
- MTextInput,
58
- },
59
-
60
- directives: {
61
- 'click-outside': {
62
- bind(el, binding, vnode) {
63
- el.clickOutsideEvent = (event) => {
64
- if (!(el === event.target || el.contains(event.target))) {
65
- vnode.context[binding.expression](event);
66
- }
67
- };
68
- document.body.addEventListener('click', el.clickOutsideEvent);
69
- },
70
- unbind(el) {
71
- document.body.removeEventListener('click', el.clickOutsideEvent);
72
- },
73
- },
74
- },
75
-
76
- model: {
77
- event: 'change',
78
- },
53
+ components: { MListBox, MTag, MTextInput },
79
54
 
80
55
  props: {
81
- open: {
56
+ multiple: {
82
57
  type: Boolean,
83
58
  default: false,
84
59
  },
85
- tagLabel: {
86
- type: String,
87
- default: '',
88
- },
89
60
  placeholder: {
90
61
  type: String,
91
62
  default: '',
92
63
  },
93
64
  items: {
94
65
  type: Array,
95
- default: () => [],
96
66
  required: true,
97
- },
98
- multiple: {
99
- type: Boolean,
100
- default: false,
67
+ default: () => [],
101
68
  },
102
69
  filter: {
103
70
  type: Function,
@@ -107,86 +74,48 @@ export default {
107
74
  type: String,
108
75
  default: 'No item matching your criteria found',
109
76
  },
110
- dataKeyExpr: {
111
- type: String,
112
- default: 'id',
113
- },
114
- dataTextExpr: {
115
- type: String,
116
- default: 'label',
77
+ sort: {
78
+ type: Boolean,
79
+ default: false,
117
80
  },
118
- dataValueExpr: {
81
+ labelTag: {
119
82
  type: String,
120
- default: 'value',
83
+ default: '',
121
84
  },
122
- value: {
123
- type: Array,
124
- default: () => [],
85
+ open: {
86
+ type: Boolean,
87
+ default: false,
125
88
  },
126
89
  },
127
-
128
90
  data() {
129
91
  return {
130
- itemListForDropdown: this.items,
131
- isOpen: this.open,
92
+ itemListForDropdown: this.$props.items,
93
+ selected: this.$props.items,
94
+ itemDisplayed: '',
95
+ isOpen: this.$props.open,
132
96
  tagWidth: '0px',
133
- maxWidth: '17.875rem',
134
- uuid: undefined,
135
- tagValue: '',
136
- inputValue: '',
137
- listboxValue: [],
97
+ boxWidth: '288px',
138
98
  };
139
99
  },
140
-
141
100
  computed: {
142
101
  tagStyle() {
143
102
  return {
144
103
  '--tag-width': this.tagWidth,
145
- '--max-width': this.maxWidth,
146
104
  };
147
105
  },
148
- },
149
-
150
- watch: {
151
- listboxValue: function (newValue) {
152
- const textToDisplay = [];
153
- const valueExpr = this.dataValueExpr;
154
- const textExpr = this.dataTextExpr;
155
-
156
- this.tagValue = newValue;
157
-
158
- if (newValue.length) {
159
- const selectedItems = this.items.filter((item) =>
160
- newValue.includes(item[valueExpr])
161
- );
162
-
163
- selectedItems.forEach((item) => textToDisplay.push(item[textExpr]));
164
-
165
- this.inputValue = textToDisplay.join(', ');
166
- }
167
- },
168
-
169
- tagValue: {
170
- handler: function () {
171
- this.setTagWidth();
172
- },
173
- immediate: true,
174
- },
175
-
176
- value: {
177
- handler: function (value) {
178
- this.listboxValue = value;
179
- },
180
- immediate: true,
106
+ boxStyle() {
107
+ return {
108
+ '--box-width': this.boxWidth,
109
+ };
181
110
  },
182
111
  },
183
-
184
112
  mounted() {
185
- this.uuid = this._uid;
113
+ this.selectedItems();
114
+ this.tagWidthCalcul();
115
+ this.boxWidthCalcul();
186
116
  },
187
-
188
117
  methods: {
189
- setTagWidth() {
118
+ tagWidthCalcul() {
190
119
  this.$nextTick(() => {
191
120
  this.tagWidth =
192
121
  document && document.querySelector('.mc-autocomplete__tag')
@@ -194,63 +123,76 @@ export default {
194
123
  : '0px';
195
124
  });
196
125
  },
197
-
198
- clearAutocomplete() {
199
- this.listboxValue = [];
200
- this.inputValue = '';
201
- this.onChange();
202
- this.$emit('clear');
126
+ selectedItems() {
127
+ return this.selected.filter((item) => {
128
+ return item.selected;
129
+ });
203
130
  },
204
-
205
- filterList(value) {
206
- if (value.length && this.filter) {
207
- this.filter(value);
131
+ orderedItems() {
132
+ this.itemListForDropdown.sort((a, b) => {
133
+ if (a.selected === b.selected) {
134
+ return a.id - b.id;
135
+ } else if (a.selected < b.selected) {
136
+ return 1;
137
+ } else {
138
+ return -1;
139
+ }
140
+ });
141
+ },
142
+ updateList(list) {
143
+ if (!this.$props.multiple && list) {
144
+ this.itemDisplayed = list[0].text;
145
+ } else {
146
+ this.isOpen = true;
147
+ this.selectedItems();
148
+ }
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);
208
171
  } else if (value.length) {
209
172
  this.itemListForDropdown = this.itemListForDropdown.filter((item) =>
210
- item[this.dataTextExpr].toUpperCase().includes(value.toUpperCase())
173
+ item.text.toUpperCase().includes(value.toUpperCase())
211
174
  );
212
175
  } else {
213
- this.itemListForDropdown = this.items;
176
+ this.itemListForDropdown = this.$props.items;
214
177
  }
215
178
  this.$emit('list-filtered', this.itemListForDropdown);
216
179
  },
217
-
218
- onClickOutside() {
219
- this.isOpen = false;
220
- },
221
-
222
- onChange() {
223
- this.$emit('change', this.listboxValue);
224
-
225
- if (!this.multiple) {
226
- this.onClickOutside();
227
- }
180
+ boxWidthCalcul() {
181
+ this.$nextTick(() => {
182
+ this.boxWidth = document.querySelector('.mc-autocomplete').clientWidth;
183
+ console.log(this.boxWidth);
184
+ });
185
+ return;
228
186
  },
229
187
  },
230
188
  };
231
189
  </script>
232
190
 
233
191
  <style lang="scss">
234
- @import 'settings-tools/all-settings';
235
- @import 'components/c.checkbox';
236
- @import 'components/c.autocomplete';
237
-
238
- .mc-autocomplete {
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
- }
248
- }
192
+ @import 'settings-tools/_all-settings';
193
+ @import 'components/_c.autocomplete';
249
194
 
250
195
  .mc-autocomplete--multi .mc-autocomplete__trigger {
251
- overflow: hidden;
252
196
  padding-left: calc(2.9375rem + var(--tag-width));
253
- text-overflow: ellipsis;
254
- white-space: nowrap;
255
197
  }
256
198
  </style>
@@ -22,7 +22,6 @@
22
22
  v-bind="option"
23
23
  :key="option.id ? option.id : option.value"
24
24
  class="mc-field__item"
25
- :disabled="disabled"
26
25
  :checked="value ? value.includes(option.value) : undefined"
27
26
  @change="(v) => onChange(v, option.value)"
28
27
  >
@@ -125,13 +124,6 @@ export default {
125
124
  type: Boolean,
126
125
  default: false,
127
126
  },
128
- /**
129
- * Disabled
130
- */
131
- disabled: {
132
- type: Boolean,
133
- default: false,
134
- },
135
127
  },
136
128
 
137
129
  data() {