@mozaic-ds/vue 0.12.1 → 0.14.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 (31) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/mozaic-vue.adeo.css +1 -1
  3. package/dist/mozaic-vue.adeo.umd.js +978 -257
  4. package/dist/mozaic-vue.common.js +978 -257
  5. package/dist/mozaic-vue.common.js.map +1 -1
  6. package/dist/mozaic-vue.css +1 -1
  7. package/dist/mozaic-vue.umd.js +978 -257
  8. package/dist/mozaic-vue.umd.js.map +1 -1
  9. package/dist/mozaic-vue.umd.min.js +1 -1
  10. package/dist/mozaic-vue.umd.min.js.map +1 -1
  11. package/package.json +6 -6
  12. package/src/components/accordion/MAccordion.vue +14 -29
  13. package/src/components/breadcrumb/MBreadcrumb.vue +1 -0
  14. package/src/components/field/MField.vue +3 -0
  15. package/src/components/fileuploader/MFileUploader.vue +6 -1
  16. package/src/components/index.js +4 -0
  17. package/src/components/optionbutton/MOptionButton.vue +67 -0
  18. package/src/components/optionbutton/index.js +7 -0
  19. package/src/components/optioncard/MOptionCard.vue +104 -0
  20. package/src/components/optioncard/index.js +7 -0
  21. package/src/components/optiongroup/MOptionGroup.vue +18 -0
  22. package/src/components/optiongroup/index.js +7 -0
  23. package/src/components/passwordinput/MPasswordInput.vue +96 -0
  24. package/src/components/passwordinput/index.js +7 -0
  25. package/src/components/phonenumber/MPhoneNumber.vue +48 -20
  26. package/src/components/quantityselector/MQuantitySelector.vue +6 -2
  27. package/src/components/select/MSelect.vue +19 -2
  28. package/src/components/textarea/MTextArea.vue +9 -2
  29. package/src/components/textinput/MTextInput.vue +22 -2
  30. package/src/index.js +4 -0
  31. package/types/index.d.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaic-ds/vue",
3
- "version": "0.12.1",
3
+ "version": "0.14.0",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build ./src/index.js",
@@ -13,9 +13,9 @@
13
13
  "postinstall": "node postinstall.js"
14
14
  },
15
15
  "dependencies": {
16
- "@mozaic-ds/css-dev-tools": "^1.20.0",
17
- "@mozaic-ds/icons": "^1.20.0",
18
- "@mozaic-ds/styles": "^1.23.0",
16
+ "@mozaic-ds/css-dev-tools": "^1.24.0",
17
+ "@mozaic-ds/icons": "^1.25.0",
18
+ "@mozaic-ds/styles": "^1.25.0",
19
19
  "@mozaic-ds/web-fonts": "^1.22.0",
20
20
  "core-js": "^3.18.3",
21
21
  "libphonenumber-js": "^1.9.37",
@@ -26,8 +26,8 @@
26
26
  "devDependencies": {
27
27
  "@babel/core": "^7.15.8",
28
28
  "@babel/eslint-parser": "^7.15.8",
29
- "@vue/cli-plugin-babel": "^4.5.13",
30
- "@vue/cli-service": "^4.5.13",
29
+ "@vue/cli-plugin-babel": "^4.5.15",
30
+ "@vue/cli-service": "^4.5.15",
31
31
  "@vue/compiler-sfc": "^3.2.20",
32
32
  "@vue/eslint-config-prettier": "^6.0.0",
33
33
  "babel-eslint": "^10.1.0",
@@ -2,20 +2,22 @@
2
2
  <div class="mc-accordion" :class="{ 'mc-accordion--s': size === 's' }">
3
3
  <input
4
4
  :id="id"
5
- v-model="checked"
5
+ ref="checkbox"
6
6
  type="checkbox"
7
7
  class="mc-accordion__trigger"
8
8
  :disabled="disabled"
9
+ :checked="open"
10
+ @change="$emit('update:open', $event.target.checked)"
9
11
  />
10
12
  <div
11
13
  :class="['mc-accordion__header', setHeaderClasses]"
12
- :aria-expanded="checked"
13
- @click="onClick"
14
+ :aria-expanded="open"
15
+ @click="$refs.checkbox.click()"
14
16
  >
15
17
  <slot name="beforeLabel" />
16
18
  <label
17
19
  :for="id"
18
- :aria-expanded="checked"
20
+ :aria-expanded="open"
19
21
  :class="['mc-accordion__header__label', setLabelClasses]"
20
22
  @click.stop
21
23
  >
@@ -40,6 +42,11 @@ export default {
40
42
  MIcon,
41
43
  },
42
44
 
45
+ model: {
46
+ prop: 'open',
47
+ event: 'change',
48
+ },
49
+
43
50
  props: {
44
51
  id: {
45
52
  type: String,
@@ -72,12 +79,6 @@ export default {
72
79
  },
73
80
  },
74
81
 
75
- data: function () {
76
- return {
77
- checked: this.open,
78
- };
79
- },
80
-
81
82
  computed: {
82
83
  setHeaderClasses() {
83
84
  return {
@@ -95,23 +96,6 @@ export default {
95
96
  };
96
97
  },
97
98
  },
98
-
99
- watch: {
100
- open: function () {
101
- this.checked = !this.checked;
102
- },
103
- checked: function () {
104
- this.$emit('update:open', this.checked);
105
- },
106
- },
107
-
108
- methods: {
109
- onClick() {
110
- if (this.disabled === false) {
111
- this.checked = !this.checked;
112
- }
113
- },
114
- },
115
99
  };
116
100
  </script>
117
101
 
@@ -125,10 +109,11 @@ export default {
125
109
  align-items: center;
126
110
 
127
111
  &__label {
128
- display: flex;
129
112
  align-items: center;
130
- white-space: nowrap;
113
+ display: flex;
131
114
  cursor: pointer;
115
+ gap: $mu050;
116
+ white-space: nowrap;
132
117
 
133
118
  &--with-before-slot {
134
119
  padding-left: $mu100;
@@ -22,6 +22,7 @@
22
22
  ]"
23
23
  :aria-current="index != items.length - 1 ? null : 'page'"
24
24
  size="s"
25
+ :router="item.router"
25
26
  @click="$emit('link-clicked', item)"
26
27
  >
27
28
  {{ item.text }}
@@ -23,6 +23,9 @@
23
23
  <script>
24
24
  export default {
25
25
  name: 'MField',
26
+ provide: {
27
+ cssFieldElementClass: 'mc-field__element',
28
+ },
26
29
  props: {
27
30
  id: {
28
31
  type: String,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="mc-fileuploader">
2
+ <div class="mc-fileuploader" :class="cssFieldElementClass">
3
3
  <input
4
4
  :id="id"
5
5
  ref="fileUpload"
@@ -45,6 +45,11 @@ export default {
45
45
  components: {
46
46
  MFileResult,
47
47
  },
48
+ inject: {
49
+ cssFieldElementClass: {
50
+ default: '',
51
+ },
52
+ },
48
53
  inheritAttrs: false,
49
54
  props: {
50
55
  id: {
@@ -19,7 +19,11 @@ export { MLayer } from './layer';
19
19
  export { MLink } from './link';
20
20
  export { MModal } from './modal';
21
21
  export { MNotification } from './notification';
22
+ export { MOptionButton } from './optionbutton';
23
+ export { MOptionCard } from './optioncard';
24
+ export { MOptionGroup } from './optiongroup';
22
25
  export { MPagination } from './pagination';
26
+ export { MPasswordInput } from './passwordinput';
23
27
  export { MPhoneNumber } from './phonenumber';
24
28
  export { MProgress } from './progressbar';
25
29
  export { MQuantitySelector } from './quantityselector';
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <div
3
+ class="mc-option-button"
4
+ :class="{ 'mc-option-button--full': fullWidth }"
5
+ >
6
+ <input
7
+ :id="id"
8
+ type="radio"
9
+ class="mc-option-button__input"
10
+ :name="name"
11
+ :checked="checked"
12
+ :disabled="disabled"
13
+ v-bind="inputAttrs"
14
+ @change="$emit('change', $event.target.checked)"
15
+ />
16
+ <label :for="id" class="mc-option-button__label">
17
+ {{ label }}
18
+ </label>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ export default {
24
+ name: 'MOptionButton',
25
+
26
+ model: {
27
+ prop: 'checked',
28
+ event: 'change',
29
+ },
30
+
31
+ props: {
32
+ id: {
33
+ type: String,
34
+ required: true,
35
+ },
36
+ label: {
37
+ type: String,
38
+ required: true,
39
+ },
40
+ name: {
41
+ type: String,
42
+ default: null,
43
+ },
44
+ checked: {
45
+ type: Boolean,
46
+ default: false,
47
+ },
48
+ disabled: {
49
+ type: Boolean,
50
+ default: false,
51
+ },
52
+ fullWidth: {
53
+ type: Boolean,
54
+ default: false,
55
+ },
56
+ inputAttrs: {
57
+ type: Object,
58
+ default: () => ({}),
59
+ },
60
+ },
61
+ };
62
+ </script>
63
+
64
+ <style lang="scss">
65
+ @import 'settings-tools/_all-settings';
66
+ @import 'components/c.option-button';
67
+ </style>
@@ -0,0 +1,7 @@
1
+ import MOptionButton from './MOptionButton.vue';
2
+
3
+ MOptionButton.install = function (Vue) {
4
+ Vue.component(MOptionButton.name, MOptionButton);
5
+ };
6
+
7
+ export { MOptionButton };
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <div class="mc-option-card" :class="setClasses">
3
+ <input
4
+ :id="id"
5
+ :type="setType"
6
+ class="mc-option-card__input"
7
+ :class="setInputClasses"
8
+ :name="name"
9
+ :required="required"
10
+ :checked="checked"
11
+ v-bind="inputAttrs"
12
+ @change="$emit('change', $event.target.checked)"
13
+ />
14
+ <label :for="id" class="mc-option-card__label">
15
+ <span class="mc-option-card__label-text">{{ label }}</span>
16
+ </label>
17
+ <div class="mc-option-card__content">
18
+ <slot />
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ export default {
25
+ name: 'MOptionCard',
26
+
27
+ model: {
28
+ prop: 'checked',
29
+ event: 'change',
30
+ },
31
+
32
+ props: {
33
+ id: {
34
+ type: String,
35
+ required: true,
36
+ },
37
+ type: {
38
+ type: String,
39
+ default: 'radio',
40
+ validator: (value) => ['radio', 'checkbox'].includes(value),
41
+ },
42
+ label: {
43
+ type: String,
44
+ required: true,
45
+ },
46
+ name: {
47
+ type: String,
48
+ default: null,
49
+ },
50
+ checked: {
51
+ type: Boolean,
52
+ default: false,
53
+ },
54
+ required: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
58
+ index: {
59
+ type: Number,
60
+ default: 1,
61
+ },
62
+ centered: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ small: {
67
+ type: Boolean,
68
+ default: false,
69
+ },
70
+ noPadding: {
71
+ type: Boolean,
72
+ default: false,
73
+ },
74
+ inputAttrs: {
75
+ type: Object,
76
+ default: () => ({}),
77
+ },
78
+ },
79
+
80
+ computed: {
81
+ setType() {
82
+ return this.type === 'checkbox' ? 'checkbox' : 'radio';
83
+ },
84
+ setClasses() {
85
+ return {
86
+ 'mc-option-card--centered': this.centered,
87
+ 'mc-option-card--no-padding': this.noPadding,
88
+ 'mc-option-card--small': this.small,
89
+ };
90
+ },
91
+ setInputClasses() {
92
+ return {
93
+ 'mc-checkbox__input': this.type === 'checkbox',
94
+ 'mc-radio__input': this.type === 'radio',
95
+ };
96
+ },
97
+ },
98
+ };
99
+ </script>
100
+
101
+ <style lang="scss">
102
+ @import 'settings-tools/all-settings';
103
+ @import 'components/c.option-card';
104
+ </style>
@@ -0,0 +1,7 @@
1
+ import MOptionCard from './MOptionCard.vue';
2
+
3
+ MOptionCard.install = function (Vue) {
4
+ Vue.component(MOptionCard.name, MOptionCard);
5
+ };
6
+
7
+ export { MOptionCard };
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <component :is="htmlTag" class="mc-option-group">
3
+ {{ label }}
4
+ </component>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'MOptionGroup',
10
+
11
+ props: {
12
+ htmlTag: {
13
+ type: String,
14
+ default: 'div',
15
+ },
16
+ },
17
+ };
18
+ </script>
@@ -0,0 +1,7 @@
1
+ import MOptionGroup from './MOptionGroup.vue';
2
+
3
+ MOptionGroup.install = function (Vue) {
4
+ Vue.component(MOptionGroup.name, MOptionGroup);
5
+ };
6
+
7
+ export { MOptionGroup };
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div class="mc-password-input" :class="cssFieldElementClass">
3
+ <input
4
+ :type="setType"
5
+ :required="required"
6
+ class="mc-text-input mc-password-input__control"
7
+ :class="setInputClasses"
8
+ :aria-invalid="isInvalid"
9
+ />
10
+
11
+ <button
12
+ ref="button"
13
+ type="button"
14
+ class="mc-password-input__button"
15
+ role="switch"
16
+ :aria-pressed="setAriaPressed"
17
+ @click="onClick"
18
+ >
19
+ {{ setButtonLabel }}
20
+ </button>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: 'MPasswordInput',
27
+
28
+ inject: {
29
+ cssFieldElementClass: {
30
+ default: '',
31
+ },
32
+ },
33
+
34
+ props: {
35
+ required: {
36
+ type: Boolean,
37
+ default: false,
38
+ },
39
+ value: {
40
+ type: [String, Number],
41
+ default: null,
42
+ },
43
+ isValid: {
44
+ type: Boolean,
45
+ default: false,
46
+ },
47
+ isInvalid: {
48
+ type: Boolean,
49
+ default: false,
50
+ },
51
+ buttonLabel: {
52
+ type: Object,
53
+ default: function () {
54
+ return { show: 'Show', hide: 'Hide' };
55
+ },
56
+ },
57
+ },
58
+
59
+ data: function () {
60
+ return {
61
+ isVisible: false,
62
+ };
63
+ },
64
+
65
+ computed: {
66
+ setType() {
67
+ return this.isVisible ? 'text' : 'password';
68
+ },
69
+ setInputClasses() {
70
+ return {
71
+ 'is-valid': this.isValid,
72
+ 'is-invalid': this.isInvalid,
73
+ };
74
+ },
75
+ setAriaPressed() {
76
+ return this.isVisible ? 'true' : 'false';
77
+ },
78
+ setButtonLabel() {
79
+ return this.isVisible ? this.buttonLabel.hide : this.buttonLabel.show;
80
+ },
81
+ },
82
+
83
+ methods: {
84
+ onClick() {
85
+ const aria = this.$refs.button.getAttribute('aria-pressed') === 'false';
86
+ this.isVisible = aria;
87
+ },
88
+ },
89
+ };
90
+ </script>
91
+
92
+ <style lang="scss">
93
+ @import 'settings-tools/_all-settings';
94
+ @import 'components/_c.text-input';
95
+ @import 'components/_c.password-input';
96
+ </style>
@@ -0,0 +1,7 @@
1
+ import MPasswordInput from './MPasswordInput.vue';
2
+
3
+ MPasswordInput.install = function (Vue) {
4
+ Vue.component(MPasswordInput.name, MPasswordInput);
5
+ };
6
+
7
+ export { MPasswordInput };
@@ -1,7 +1,10 @@
1
1
  <template>
2
2
  <div
3
3
  class="mc-phone-number"
4
- :class="{ 'mc-phone-number--focused': isCountriesListOpened }"
4
+ :class="[
5
+ { 'mc-phone-number--focused': isCountriesListOpened },
6
+ cssFieldElementClass,
7
+ ]"
5
8
  >
6
9
  <div
7
10
  v-if="isCountriesListOpened"
@@ -72,9 +75,11 @@
72
75
  :placeholder="placeholder"
73
76
  :maxlength="maxlength"
74
77
  @blur="onChangePhoneNumber"
75
- @focus="(event) => formatOnBlur ? cleanFormat(event) : null"
78
+ @focus="(event) => (formatOnBlur ? cleanFormat(event) : null)"
76
79
  @keyup="onKeyPressPhoneNumber"
77
- @keydown.backspace="(event) => formatOnBlur ? null : backspaceFunction(event)"
80
+ @keydown.backspace="
81
+ (event) => (formatOnBlur ? null : backspaceFunction(event))
82
+ "
78
83
  />
79
84
  </div>
80
85
  </template>
@@ -85,7 +90,7 @@ import CountryFlag from 'vue-country-flag';
85
90
  import {
86
91
  parsePhoneNumber,
87
92
  formatIncompletePhoneNumber,
88
- AsYouType
93
+ AsYouType,
89
94
  } from 'libphonenumber-js';
90
95
  import { getExampleNumber } from 'libphonenumber-js/max';
91
96
  import examples from 'libphonenumber-js/examples.mobile.json';
@@ -95,6 +100,11 @@ export default {
95
100
  components: {
96
101
  CountryFlag,
97
102
  },
103
+ inject: {
104
+ cssFieldElementClass: {
105
+ default: '',
106
+ },
107
+ },
98
108
  props: {
99
109
  countries: {
100
110
  type: Array,
@@ -156,7 +166,10 @@ export default {
156
166
  init() {
157
167
  if (this.hasValue) {
158
168
  try {
159
- const parsedValue = parsePhoneNumber(this.value, this.countries[0].shortName);
169
+ const parsedValue = parsePhoneNumber(
170
+ this.value,
171
+ this.countries[0].shortName
172
+ );
160
173
  this.phoneNumber = parsedValue.formatNational();
161
174
  this.selectedCountry =
162
175
  this.countries.find(
@@ -224,7 +237,7 @@ export default {
224
237
  },
225
238
 
226
239
  onKeyPressPhoneNumber(event) {
227
- if(this.formatOnBlur){
240
+ if (this.formatOnBlur) {
228
241
  const phoneNumber = event ? event.target.value : this.phoneNumber;
229
242
  try {
230
243
  this.$emit(
@@ -245,21 +258,36 @@ export default {
245
258
  }
246
259
  } else {
247
260
  let caretPosition = event.target.selectionStart;
248
- if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode<= 105)) {
261
+ if (
262
+ (event.keyCode >= 48 && event.keyCode <= 57) ||
263
+ (event.keyCode >= 96 && event.keyCode <= 105)
264
+ ) {
249
265
  const asYouType = new AsYouType(this.selectedCountry.shortName);
250
266
  const phone = asYouType.input(event.target.value);
251
267
  event.target.value = phone;
252
268
  this.$nextTick(() => {
253
269
  const charBefore = event.target.value.charAt(caretPosition - 1);
254
270
  const charAfter = event.target.value.charAt(caretPosition + 1);
255
- caretPosition = charBefore === ' ' || charBefore === '-' ? caretPosition + 1 : caretPosition;
256
- caretPosition = charAfter === '-' || charAfter === ')' ? caretPosition + 2 : caretPosition;
271
+ caretPosition =
272
+ charBefore === ' ' || charBefore === '-'
273
+ ? caretPosition + 1
274
+ : caretPosition;
275
+ caretPosition =
276
+ charAfter === '-' || charAfter === ')'
277
+ ? caretPosition + 2
278
+ : caretPosition;
257
279
  event.target.setSelectionRange(caretPosition, caretPosition);
258
- });
280
+ });
259
281
  try {
260
282
  this.$emit('input', asYouType.input(event.target.value));
261
283
  } catch (error) {
262
- this.$emit('input', formatIncompletePhoneNumber(event.target.value, this.selectedCountry.shortName));
284
+ this.$emit(
285
+ 'input',
286
+ formatIncompletePhoneNumber(
287
+ event.target.value,
288
+ this.selectedCountry.shortName
289
+ )
290
+ );
263
291
  }
264
292
  }
265
293
  }
@@ -285,14 +313,14 @@ export default {
285
313
  );
286
314
  }
287
315
  this.phoneNumber = parsePhoneNumber(
288
- phoneNumber,
289
- this.selectedCountry.shortName
290
- ).formatNational();
291
- if(event && event.target) {
316
+ phoneNumber,
317
+ this.selectedCountry.shortName
318
+ ).formatNational();
319
+ if (event && event.target) {
292
320
  event.target.value = parsePhoneNumber(
293
- phoneNumber,
294
- this.selectedCountry.shortName
295
- ).formatNational();
321
+ phoneNumber,
322
+ this.selectedCountry.shortName
323
+ ).formatNational();
296
324
  }
297
325
  },
298
326
  onChangeCountry(country) {
@@ -316,9 +344,9 @@ export default {
316
344
  this.$emit('close-countries-list');
317
345
  this.isCountriesListOpened = false;
318
346
  },
319
- cleanFormat(event){
347
+ cleanFormat(event) {
320
348
  this.phoneNumber = formatIncompletePhoneNumber(event.target.value);
321
- }
349
+ },
322
350
  },
323
351
  };
324
352
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="mc-quantity-selector">
2
+ <div class="mc-quantity-selector" :class="cssFieldElementClass">
3
3
  <m-button
4
4
  class="mc-quantity-selector__button-left"
5
5
  theme="bordered"
@@ -58,7 +58,11 @@ export default {
58
58
  MButton,
59
59
  MTextInputField,
60
60
  },
61
-
61
+ inject: {
62
+ cssFieldElementClass: {
63
+ default: '',
64
+ },
65
+ },
62
66
  props: {
63
67
  id: {
64
68
  type: String,