@mozaic-ds/vue 0.14.3-beta.0 → 0.16.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 (33) hide show
  1. package/dist/mozaic-vue.adeo.css +1 -1
  2. package/dist/mozaic-vue.adeo.umd.js +692 -137
  3. package/dist/mozaic-vue.common.js +692 -137
  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 +692 -137
  7. package/dist/mozaic-vue.umd.js.map +1 -1
  8. package/dist/mozaic-vue.umd.min.js +1 -1
  9. package/dist/mozaic-vue.umd.min.js.map +1 -1
  10. package/package.json +6 -6
  11. package/postinstall.js +0 -3
  12. package/src/components/card/MCard.vue +5 -1
  13. package/src/components/checkbox/MCheckbox.vue +12 -2
  14. package/src/components/checkbox/MCheckboxGroup.vue +149 -0
  15. package/src/components/checkbox/index.js +6 -1
  16. package/src/components/datatable/MDataTable.vue +2 -2
  17. package/src/components/index.js +3 -1
  18. package/src/components/loader/MLoader.vue +84 -0
  19. package/src/components/loader/index.js +7 -0
  20. package/src/components/modal/MModal.vue +14 -11
  21. package/src/components/optioncard/MOptionCard.vue +2 -0
  22. package/src/components/overlay/MOverlay.vue +28 -0
  23. package/src/components/overlay/MOverlayLoader.vue +43 -0
  24. package/src/components/overlay/index.js +12 -0
  25. package/src/components/phonenumber/MPhoneNumber.vue +7 -3
  26. package/src/components/quantityselector/MQuantitySelector.vue +0 -2
  27. package/src/components/radio/MRadioGroup.vue +3 -0
  28. package/src/components/select/MSelect.vue +1 -0
  29. package/src/components/tabs/MTab.vue +1 -0
  30. package/src/components/textarea/MTextArea.vue +12 -1
  31. package/src/index.js +3 -1
  32. package/types/index.d.ts +8 -0
  33. package/CHANGELOG.md +0 -592
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaic-ds/vue",
3
- "version": "0.14.3-beta.0",
3
+ "version": "0.16.0",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build ./src/index.js",
@@ -13,15 +13,15 @@
13
13
  "postinstall": "node postinstall.js"
14
14
  },
15
15
  "dependencies": {
16
- "@mozaic-ds/css-dev-tools": "^1.26.0",
17
- "@mozaic-ds/icons": "^1.26.0",
18
- "@mozaic-ds/styles": "^1.26.1",
16
+ "@mozaic-ds/css-dev-tools": "^1.27.1",
17
+ "@mozaic-ds/icons": "^1.28.0",
18
+ "@mozaic-ds/styles": "^1.28.0",
19
19
  "@mozaic-ds/web-fonts": "^1.22.0",
20
20
  "core-js": "^3.18.3",
21
- "libphonenumber-js": "^1.9.37",
21
+ "libphonenumber-js": "1.9.50",
22
22
  "postcss-scss": "^4.0.1",
23
23
  "vue": "^2.6.14",
24
- "vue-country-flag": "^2.2.0"
24
+ "vue-country-flag": "2.3.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@babel/core": "^7.15.8",
package/postinstall.js CHANGED
@@ -1,6 +1,3 @@
1
1
  const package = require('./package.json');
2
2
 
3
3
  console.log(`${package.name} installed`);
4
- console.log(
5
- "MTextInput change coming on the 01/12/2021. All input events will be available and will receive the event object. The blur event won't receive the value anymore."
6
- );
@@ -4,7 +4,7 @@
4
4
  class="mc-card__visual"
5
5
  :class="imageratio ? `mc-card__visual--${imageratio}` : ''"
6
6
  >
7
- <img :src="imgSrc" :alt="imgAlt" class="mc-card__img" />
7
+ <img :src="imgSrc" :loading="lazy ? 'lazy' : 'eager'" :alt="imgAlt" class="mc-card__img" />
8
8
  </figure>
9
9
  <article class="mc-card__content">
10
10
  <component :is="titleTag" class="mc-card__title">
@@ -36,6 +36,10 @@ export default {
36
36
  type: String,
37
37
  required: true,
38
38
  },
39
+ lazy: {
40
+ type: Boolean,
41
+ default: false
42
+ },
39
43
  outlined: {
40
44
  type: Boolean,
41
45
  default: false,
@@ -1,14 +1,16 @@
1
1
  <template>
2
2
  <div v-if="hasLabel" class="mc-checkbox">
3
3
  <input
4
+ v-bind="$attrs"
4
5
  :id="id"
5
6
  ref="input"
6
7
  :name="name"
7
8
  type="checkbox"
8
9
  class="mc-checkbox__input"
9
- :disabled="disabled"
10
10
  :class="setInputClasses"
11
11
  :checked="checked"
12
+ :required="required"
13
+ :disabled="disabled"
12
14
  @change="$emit('change', $event.target.checked)"
13
15
  />
14
16
  <label :for="id" class="mc-checkbox__label">
@@ -20,14 +22,16 @@
20
22
 
21
23
  <input
22
24
  v-else
25
+ v-bind="$attrs"
23
26
  :id="id"
24
27
  ref="input"
25
28
  :name="name"
26
29
  type="checkbox"
27
30
  class="mc-checkbox__input"
28
- :disabled="disabled"
29
31
  :class="setInputClasses"
30
32
  :checked="checked"
33
+ :required="required"
34
+ :disabled="disabled"
31
35
  @change="$emit('change', $event.target.checked)"
32
36
  />
33
37
  </template>
@@ -36,6 +40,8 @@
36
40
  export default {
37
41
  name: 'MCheckbox',
38
42
 
43
+ inheritAttrs: false,
44
+
39
45
  model: {
40
46
  prop: 'checked',
41
47
  event: 'change',
@@ -62,6 +68,10 @@ export default {
62
68
  type: Boolean,
63
69
  default: false,
64
70
  },
71
+ required: {
72
+ type: Boolean,
73
+ default: false,
74
+ },
65
75
  indeterminate: {
66
76
  type: Boolean,
67
77
  default: false,
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <fieldset class="mc-field mc-field--group">
3
+ <legend class="mc-field__legend">
4
+ {{ legend }}
5
+ <span
6
+ v-if="requirementText"
7
+ class="mc-field__requirement"
8
+ aria-hidden="true"
9
+ >
10
+ {{ requirementText }}
11
+ </span>
12
+ </legend>
13
+ <span v-if="helpId && helpText" :id="helpId" class="mc-field__help">
14
+ {{ helpText }}
15
+ </span>
16
+ <div
17
+ class="mc-field__container"
18
+ :class="{ 'mc-field__container--inline': inline }"
19
+ >
20
+ <m-checkbox
21
+ v-for="option in options"
22
+ v-bind="option"
23
+ :key="option.id ? option.id : option.value"
24
+ class="mc-field__item"
25
+ :checked="value ? value.includes(option.value) : undefined"
26
+ @change="(v) => onChange(v, option.value)"
27
+ />
28
+ </div>
29
+ <span
30
+ v-if="errorId && errorMessage"
31
+ :id="errorId"
32
+ class="mc-field__error-message"
33
+ >
34
+ {{ errorMessage }}
35
+ </span>
36
+ </fieldset>
37
+ </template>
38
+
39
+ <script>
40
+ import MCheckbox from './MCheckbox.vue';
41
+
42
+ export default {
43
+ name: 'MCheckboxGroup',
44
+
45
+ components: {
46
+ MCheckbox,
47
+ },
48
+
49
+ model: {
50
+ event: 'change',
51
+ },
52
+
53
+ props: {
54
+ /**
55
+ * Label of the whole group of checkboxes
56
+ */
57
+ legend: {
58
+ type: String,
59
+ required: true,
60
+ },
61
+ /**
62
+ * Property used to manage the values checked by v-model
63
+ * (Do not use directly)
64
+ * @ignore
65
+ */
66
+ value: {
67
+ type: Array,
68
+ default: undefined,
69
+ },
70
+ /**
71
+ * An array of objects to provide all the values and attributes related to a checkbox
72
+ */
73
+ options: {
74
+ type: Array,
75
+ default: undefined,
76
+ },
77
+ /**
78
+ * Text that indicate if one or more elements of the group are mandatory
79
+ */
80
+ requirementText: {
81
+ type: String,
82
+ default: undefined,
83
+ },
84
+ /**
85
+ * Text providing relevant or additional information to ensure that the user understands the purpose of the selection.
86
+ */
87
+ helpText: {
88
+ type: String,
89
+ default: undefined,
90
+ },
91
+ /**
92
+ * For accessibility reasons a `helpId` must be defined when using a `helpText`
93
+ */
94
+ // TODO: See if it is possible to automatically generate this id in the @next version
95
+ helpId: {
96
+ type: String,
97
+ default: undefined,
98
+ },
99
+ /**
100
+ * Text below the group of checkboxes explaining the reason for the error following the user selection.
101
+ */
102
+ errorMessage: {
103
+ type: String,
104
+ default: undefined,
105
+ },
106
+ /**
107
+ * For accessibility reasons a `errorId` must be defined when using a `errorMessage`
108
+ */
109
+ // TODO: See if it is possible to automatically generate this id in the @next version
110
+ errorId: {
111
+ type: String,
112
+ default: undefined,
113
+ },
114
+ /**
115
+ * Position the inputs horizontally
116
+ */
117
+ inline: {
118
+ type: Boolean,
119
+ default: false,
120
+ },
121
+ },
122
+
123
+ data() {
124
+ return {
125
+ checkboxesValues: [],
126
+ };
127
+ },
128
+
129
+ methods: {
130
+ onChange(isChecked, value) {
131
+ let values = this.checkboxesValues;
132
+
133
+ if (isChecked && !values.includes(value)) {
134
+ values.push(value);
135
+ } else {
136
+ values = values.filter((key) => key !== value);
137
+ }
138
+
139
+ this.$emit('change', values);
140
+ this.checkboxesValues = values;
141
+ },
142
+ },
143
+ };
144
+ </script>
145
+
146
+ <style lang="scss">
147
+ @import 'settings-tools/_all-settings';
148
+ @import 'components/_c.fields';
149
+ </style>
@@ -1,7 +1,12 @@
1
1
  import MCheckbox from './MCheckbox.vue';
2
+ import MCheckboxGroup from './MCheckboxGroup.vue';
2
3
 
3
4
  MCheckbox.install = function (Vue) {
4
5
  Vue.component(MCheckbox.name, MCheckbox);
5
6
  };
6
7
 
7
- export { MCheckbox };
8
+ MCheckboxGroup.install = function (Vue) {
9
+ Vue.component(MCheckboxGroup.name, MCheckboxGroup);
10
+ };
11
+
12
+ export { MCheckbox, MCheckboxGroup };
@@ -348,6 +348,8 @@ export default {
348
348
 
349
349
  if (this.total) {
350
350
  size = Math.ceil(this.total / this.pagerOptions.value);
351
+ } else {
352
+ size = parseInt(this.pagingOptions.index);
351
353
  }
352
354
 
353
355
  return size;
@@ -474,8 +476,6 @@ export default {
474
476
  }
475
477
 
476
478
  try {
477
- this.total = Array.isArray(this.source) ? this.source.length : this.total;
478
-
479
479
  const options = buildOptions(
480
480
  this.pagingOptions.enabled,
481
481
  this.getPageValue,
@@ -8,7 +8,7 @@ export { MBadge } from './badge';
8
8
  export { MBreadcrumb } from './breadcrumb';
9
9
  export { MButton } from './button';
10
10
  export { MCard } from './card';
11
- export { MCheckbox } from './checkbox';
11
+ export { MCheckbox, MCheckboxGroup } from './checkbox';
12
12
  export { MDataTable, MDataTableHeader } from './datatable';
13
13
  export { MField } from './field';
14
14
  export { MFileUploader } from './fileuploader';
@@ -17,11 +17,13 @@ export { MHero } from './hero';
17
17
  export { MIcon } from './icon';
18
18
  export { MLayer } from './layer';
19
19
  export { MLink } from './link';
20
+ export { MLoader } from './loader';
20
21
  export { MModal } from './modal';
21
22
  export { MNotification } from './notification';
22
23
  export { MOptionButton } from './optionbutton';
23
24
  export { MOptionCard } from './optioncard';
24
25
  export { MOptionGroup } from './optiongroup';
26
+ export { MOverlay, MOverlayLoader } from './overlay';
25
27
  export { MPagination } from './pagination';
26
28
  export { MPasswordInput } from './passwordinput';
27
29
  export { MPhoneNumber } from './phonenumber';
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="mc-loader" :class="setClasses">
3
+ <span class="mc-loader__spinner">
4
+ <svg
5
+ class="mc-loader__icon"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ :viewBox="viewBox"
8
+ >
9
+ <circle class="mc-loader__path" cx="50%" cy="50%" :r="pathR" />
10
+ </svg>
11
+ </span>
12
+
13
+ <span v-if="text" class="mc-loader__text">{{ text }}</span>
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: 'MLoader',
20
+
21
+ props: {
22
+ /**
23
+ * Loader size
24
+ * @values s, m , l
25
+ */
26
+ size: {
27
+ type: String,
28
+ default: 'm',
29
+ validator: (value) => ['s', 'm', 'l'].includes(value),
30
+ },
31
+
32
+ /**
33
+ * Loader theme
34
+ * @values dark, light, primary
35
+ */
36
+ theme: {
37
+ type: String,
38
+ default: 'primary',
39
+ validator: (value) => ['dark', 'light', 'primary'].includes(value),
40
+ },
41
+
42
+ /**
43
+ * Loader text - when using the loader inside an overlay
44
+ */
45
+ text: {
46
+ type: String,
47
+ default: undefined,
48
+ },
49
+ },
50
+
51
+ computed: {
52
+ setClasses() {
53
+ const classes = [];
54
+
55
+ if (this.size && this.size !== 'm') {
56
+ classes.push(`mc-loader--${this.size}`);
57
+ }
58
+
59
+ if (this.theme && this.theme !== 'primary') {
60
+ classes.push(`mc-loader--${this.theme}`);
61
+ }
62
+
63
+ return classes;
64
+ },
65
+
66
+ viewBox() {
67
+ return this.size === 'm'
68
+ ? '0 0 32 32'
69
+ : this.size === 's'
70
+ ? '0 0 24 24'
71
+ : '0 0 64 64';
72
+ },
73
+
74
+ pathR() {
75
+ return this.size === 'm' ? 9 : this.size === 's' ? 6 : 19;
76
+ },
77
+ },
78
+ };
79
+ </script>
80
+
81
+ <style lang="scss">
82
+ @import 'settings-tools/all-settings';
83
+ @import 'components/c.loader';
84
+ </style>
@@ -0,0 +1,7 @@
1
+ import MLoader from './MLoader.vue';
2
+
3
+ MLoader.install = function (Vue) {
4
+ Vue.component(MLoader.name, MLoader);
5
+ };
6
+
7
+ export { MLoader };
@@ -97,17 +97,20 @@ export default {
97
97
  },
98
98
 
99
99
  watch: {
100
- open(isOpen) {
101
- this.$nextTick(() => {
102
- if (isOpen) {
103
- this.trapFocus();
104
- this.setFocusOnModal();
105
- this.setOverflow();
106
- this.$emit('modal-opened');
107
- } else {
108
- this.$emit('modal-closed');
109
- }
110
- });
100
+ open: {
101
+ immediate: true,
102
+ handler: function (isOpen) {
103
+ this.$nextTick(() => {
104
+ if (isOpen) {
105
+ this.trapFocus();
106
+ this.setFocusOnModal();
107
+ this.setOverflow();
108
+ this.$emit('modal-opened');
109
+ } else {
110
+ this.$emit('modal-closed');
111
+ }
112
+ });
113
+ },
111
114
  },
112
115
  },
113
116
 
@@ -102,6 +102,7 @@ export default {
102
102
  @import 'settings-tools/all-settings';
103
103
  @import 'components/c.option-card';
104
104
 
105
+ /* stylelint-disable */
105
106
  // temporary fix
106
107
  .mc-option-card {
107
108
  $parent: get-parent-selector(&);
@@ -125,4 +126,5 @@ export default {
125
126
  }
126
127
  }
127
128
  }
129
+ /* stylelint-enable */
128
130
  </style>
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <div class="mc-overlay" :class="{ 'is-visible': isVisible }">
3
+ <!-- @slot Use this slot to insert a centered content inside the overlay -->
4
+ <slot />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ name: 'MOverlay',
11
+
12
+ props: {
13
+ /**
14
+ * Define if the overlay is visible or not
15
+ * @values false, true
16
+ */
17
+ isVisible: {
18
+ type: Boolean,
19
+ default: false,
20
+ },
21
+ },
22
+ };
23
+ </script>
24
+
25
+ <style lang="scss">
26
+ @import 'settings-tools/all-settings';
27
+ @import 'components/c.overlay';
28
+ </style>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div>
3
+ <div class="mc-overlay-loader" :class="{ 'is-visible': isVisible }">
4
+ <MLoader size="l" theme="light" :text="text" />
5
+ </div>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import MLoader from '../loader/MLoader.vue';
11
+
12
+ export default {
13
+ name: 'MOverlayLoader',
14
+
15
+ components: {
16
+ MLoader,
17
+ },
18
+
19
+ props: {
20
+ /**
21
+ * Define if the overlay is visible or not
22
+ * @values false, true
23
+ */
24
+ isVisible: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+
29
+ /**
30
+ * Loader text
31
+ */
32
+ text: {
33
+ type: String,
34
+ default: undefined,
35
+ },
36
+ },
37
+ };
38
+ </script>
39
+
40
+ <style lang="scss">
41
+ @import 'settings-tools/all-settings';
42
+ @import 'components/c.overlay';
43
+ </style>
@@ -0,0 +1,12 @@
1
+ import MOverlay from './MOverlay.vue';
2
+ import MOverlayLoader from './MOverlayLoader.vue';
3
+
4
+ MOverlay.install = function (Vue) {
5
+ Vue.component(MOverlay.name, MOverlay);
6
+ };
7
+
8
+ MOverlayLoader.install = function (Vue) {
9
+ Vue.component(MOverlayLoader.name, MOverlayLoader);
10
+ };
11
+
12
+ export { MOverlay, MOverlayLoader };
@@ -358,10 +358,14 @@ export default {
358
358
 
359
359
  .mc-phone-number {
360
360
  span.flag {
361
+ /* stylelint-disable */
361
362
  background-repeat: no-repeat;
362
- padding-right: 1rem;
363
- transform: scale(0.5, 1) !important;
364
- height: 1rem;
363
+ transform: scale(0.46153846153);
364
+ // For information:
365
+ // The value 0.46153846153 is obtained by the calculation 24/52
366
+ // 24 being the width in pixel desired by the design of the component
367
+ // 52 being the width in pixel defined by the country-flag component
368
+ /* stylelint-enable */
365
369
  }
366
370
 
367
371
  &__indicator,
@@ -10,7 +10,6 @@
10
10
  :disabled="currentValue === valuemin"
11
11
  :size="small ? 's' : null"
12
12
  tabindex="-1"
13
- aria-hidden="true"
14
13
  @click="decrement()"
15
14
  />
16
15
 
@@ -41,7 +40,6 @@
41
40
  :disabled="currentValue === valuemax"
42
41
  :size="small ? 's' : null"
43
42
  tabindex="-1"
44
- aria-hidden="true"
45
43
  @click="increment()"
46
44
  />
47
45
  </div>
@@ -23,6 +23,7 @@
23
23
  :key="option.id ? option.id : option.value"
24
24
  :is-invalid="isInvalid"
25
25
  :label="option.label"
26
+ :name="option.name"
26
27
  root-class="mc-field__item"
27
28
  :checked="value === option.value"
28
29
  @change="(v) => (v ? $emit('input', option.value) : null)"
@@ -77,10 +78,12 @@ export default {
77
78
  type: Boolean,
78
79
  default: false,
79
80
  },
81
+
80
82
  value: {
81
83
  type: String,
82
84
  default: null,
83
85
  },
86
+
84
87
  options: {
85
88
  type: Array,
86
89
  default() {
@@ -22,6 +22,7 @@
22
22
  {{ option.text }}
23
23
  </slot>
24
24
  </option>
25
+ <slot name="options" />
25
26
  </select>
26
27
  </template>
27
28
 
@@ -16,6 +16,7 @@
16
16
  <component
17
17
  :is="tab.href ? (tab.disabled ? 'span' : 'a') : 'button'"
18
18
  :id="tab.id"
19
+ ref="tab"
19
20
  :href="tab.href ? (!tab.disabled ? tab.href : null) : null"
20
21
  :type="!tab.href ? 'button' : null"
21
22
  :disabled="!tab.href && tab.disabled ? true : null"
@@ -7,7 +7,7 @@
7
7
  ]"
8
8
  :aria-invalid="isInvalid"
9
9
  :value="value"
10
- @input="$emit('input', $event.target.value)"
10
+ v-on="inputListeners"
11
11
  />
12
12
  </template>
13
13
 
@@ -33,6 +33,17 @@ export default {
33
33
  default: false,
34
34
  },
35
35
  },
36
+ computed: {
37
+ inputListeners: function () {
38
+ // see => https://vuejs.org/v2/guide/components-custom-events.html#Binding-Native-Events-to-Components
39
+ var vm = this;
40
+ return Object.assign({}, this.$listeners, {
41
+ input: function (event) {
42
+ vm.$emit('input', event.target.value);
43
+ },
44
+ });
45
+ },
46
+ },
36
47
  };
37
48
  </script>
38
49
 
package/src/index.js CHANGED
@@ -27,7 +27,7 @@ export { MBadge } from './components/badge/';
27
27
  export { MBreadcrumb } from './components/breadcrumb/';
28
28
  export { MButton } from './components/button/';
29
29
  export { MCard } from './components/card/';
30
- export { MCheckbox } from './components/checkbox/';
30
+ export { MCheckbox, MCheckboxGroup } from './components/checkbox/';
31
31
  export { MDataTable, MDataTableHeader } from './components/datatable';
32
32
  export { MField } from './components/field';
33
33
  export { MFileUploader } from './components/fileuploader';
@@ -36,11 +36,13 @@ export { MHero } from './components/hero';
36
36
  export { MIcon } from './components/icon';
37
37
  export { MLayer } from './components/layer';
38
38
  export { MLink } from './components/link';
39
+ export { MLoader } from './components/loader';
39
40
  export { MModal } from './components/modal';
40
41
  export { MNotification } from './components/notification';
41
42
  export { MOptionButton } from './components/optionbutton';
42
43
  export { MOptionCard } from './components/optioncard';
43
44
  export { MOptionGroup } from './components/optiongroup';
45
+ export { MOverlay, MOverlayLoader } from './components/overlay';
44
46
  export { MPagination } from './components/pagination';
45
47
  export { MPasswordInput } from './components/passwordinput';
46
48
  export { MPhoneNumber } from './components/phonenumber';