@mozaic-ds/vue 0.14.2 → 0.15.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.14.2",
3
+ "version": "0.15.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.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
21
  "libphonenumber-js": "^1.9.37",
@@ -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;
@@ -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 };
@@ -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 };
@@ -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
 
@@ -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';
package/types/index.d.ts CHANGED
@@ -14,6 +14,7 @@ declare module '@mozaic-ds/vue' {
14
14
  const MButton: VueConstructor;
15
15
  const MCard: VueConstructor;
16
16
  const MCheckbox: VueConstructor;
17
+ const MCheckboxGroup: VueConstructor;
17
18
  const MField: VueConstructor;
18
19
  const MFileUploader: VueConstructor;
19
20
  const MFlag: VueConstructor;
@@ -21,11 +22,14 @@ declare module '@mozaic-ds/vue' {
21
22
  const MIcon: VueConstructor;
22
23
  const MLayer: VueConstructor;
23
24
  const MLink: VueConstructor;
25
+ const MLoader: VueConstructor;
24
26
  const MModal: VueConstructor;
25
27
  const MNotification: VueConstructor;
26
28
  const MOptionButton: VueConstructor;
27
29
  const MOptionCard: VueConstructor;
28
30
  const MOptionGroup: VueConstructor;
31
+ const MOverlay: VueConstructor;
32
+ const MOverlayLoader: VueConstructor;
29
33
  const MPagination: VueConstructor;
30
34
  const MPasswordInput: VueConstructor;
31
35
  const MPhoneNumber: VueConstructor;
@@ -55,6 +59,7 @@ declare module '@mozaic-ds/vue' {
55
59
  MButton,
56
60
  MCard,
57
61
  MCheckbox,
62
+ MCheckboxGroup,
58
63
  MField,
59
64
  MFileUploader,
60
65
  MFlag,
@@ -62,11 +67,14 @@ declare module '@mozaic-ds/vue' {
62
67
  MIcon,
63
68
  MLayer,
64
69
  MLink,
70
+ MLoader,
65
71
  MModal,
66
72
  MNotification,
67
73
  MOptionButton,
68
74
  MOptionCard,
69
75
  MOptionGroup,
76
+ MOverlay,
77
+ MOverlayLoader,
70
78
  MPagination,
71
79
  MPasswordInput,
72
80
  MPhoneNumber,