@mozaic-ds/vue 1.0.0-beta.3 → 1.0.0-beta.5

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 (191) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +224 -82
  3. package/dist/mozaic-vue.css +1 -1
  4. package/dist/mozaic-vue.d.ts +1202 -0
  5. package/dist/mozaic-vue.js +1220 -0
  6. package/dist/mozaic-vue.js.map +1 -0
  7. package/dist/mozaic-vue.umd.cjs +2 -0
  8. package/dist/mozaic-vue.umd.cjs.map +1 -0
  9. package/env.d.ts +1 -0
  10. package/package.json +81 -50
  11. package/src/components/Contributing.mdx +118 -0
  12. package/src/components/GettingStarted.mdx +50 -0
  13. package/src/components/Introduction.mdx +54 -0
  14. package/src/components/Support.mdx +18 -0
  15. package/src/components/badge/MBadge.spec.ts +16 -0
  16. package/src/components/badge/MBadge.stories.ts +50 -0
  17. package/src/components/badge/MBadge.vue +36 -34
  18. package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
  19. package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -0
  20. package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
  21. package/src/components/button/MButton.spec.ts +191 -0
  22. package/src/components/button/MButton.stories.ts +66 -0
  23. package/src/components/button/MButton.vue +98 -154
  24. package/src/components/checkbox/MCheckbox.spec.ts +104 -0
  25. package/src/components/checkbox/MCheckbox.stories.ts +83 -0
  26. package/src/components/checkbox/MCheckbox.vue +60 -101
  27. package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
  28. package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
  29. package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
  30. package/src/components/field/MField.spec.ts +166 -0
  31. package/src/components/field/MField.stories.ts +376 -0
  32. package/src/components/field/MField.vue +78 -61
  33. package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
  34. package/src/components/fieldgroup/MFieldGroup.stories.ts +423 -0
  35. package/src/components/fieldgroup/MFieldGroup.vue +79 -0
  36. package/src/components/iconbutton/MIconButton.spec.ts +108 -0
  37. package/src/components/iconbutton/MIconButton.stories.ts +66 -0
  38. package/src/components/iconbutton/MIconButton.vue +73 -0
  39. package/src/components/link/MLink.spec.ts +154 -0
  40. package/src/components/link/MLink.stories.ts +98 -0
  41. package/src/components/link/MLink.vue +86 -109
  42. package/src/components/loader/MLoader.spec.ts +104 -0
  43. package/src/components/loader/MLoader.stories.ts +45 -0
  44. package/src/components/loader/MLoader.vue +65 -55
  45. package/src/components/overlay/MOverlay.spec.ts +51 -0
  46. package/src/components/overlay/MOverlay.stories.ts +40 -0
  47. package/src/components/overlay/MOverlay.vue +27 -19
  48. package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
  49. package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
  50. package/src/components/passwordinput/MPasswordInput.vue +129 -76
  51. package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
  52. package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
  53. package/src/components/quantityselector/MQuantitySelector.vue +160 -136
  54. package/src/components/radio/MRadio.spec.ts +104 -0
  55. package/src/components/radio/MRadio.stories.ts +68 -0
  56. package/src/components/radio/MRadio.vue +56 -39
  57. package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
  58. package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
  59. package/src/components/radiogroup/MRadioGroup.vue +79 -0
  60. package/src/components/select/MSelect.spec.ts +114 -0
  61. package/src/components/select/MSelect.stories.ts +101 -0
  62. package/src/components/select/MSelect.vue +77 -119
  63. package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
  64. package/src/components/statusbadge/MStatusBadge.vue +40 -0
  65. package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
  66. package/src/components/statusdot/MStatusDot.spec.ts +51 -0
  67. package/src/components/statusdot/MStatusDot.stories.ts +48 -0
  68. package/src/components/statusdot/MStatusDot.vue +36 -0
  69. package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
  70. package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
  71. package/src/components/statusnotification/MStatusNotification.vue +106 -0
  72. package/src/components/textarea/MTextArea.spec.ts +112 -0
  73. package/src/components/textarea/MTextArea.stories.ts +67 -0
  74. package/src/components/textarea/MTextArea.vue +81 -42
  75. package/src/components/textinput/MTextInput.spec.ts +121 -0
  76. package/src/components/textinput/MTextInput.stories.ts +114 -0
  77. package/src/components/textinput/MTextInput.vue +127 -47
  78. package/src/components/toggle/MToggle.spec.ts +99 -0
  79. package/src/components/toggle/MToggle.stories.ts +68 -0
  80. package/src/components/toggle/MToggle.vue +63 -103
  81. package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
  82. package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
  83. package/src/components/togglegroup/MToggleGroup.vue +97 -0
  84. package/src/components/usingIcons.mdx +43 -0
  85. package/src/components/usingPresets.mdx +125 -0
  86. package/src/main.ts +47 -0
  87. package/dist/demo.html +0 -1
  88. package/dist/mozaic-vue.adeo.css +0 -45
  89. package/dist/mozaic-vue.adeo.umd.js +0 -41775
  90. package/dist/mozaic-vue.common.js +0 -41765
  91. package/dist/mozaic-vue.common.js.map +0 -1
  92. package/dist/mozaic-vue.umd.js +0 -41776
  93. package/dist/mozaic-vue.umd.js.map +0 -1
  94. package/dist/mozaic-vue.umd.min.js +0 -4
  95. package/dist/mozaic-vue.umd.min.js.map +0 -1
  96. package/postinstall.js +0 -3
  97. package/src/components/accordion/MAccordion.vue +0 -128
  98. package/src/components/accordion/index.js +0 -7
  99. package/src/components/autocomplete/MAutocomplete.vue +0 -198
  100. package/src/components/autocomplete/index.js +0 -7
  101. package/src/components/badge/index.js +0 -7
  102. package/src/components/breadcrumb/index.js +0 -7
  103. package/src/components/button/index.js +0 -7
  104. package/src/components/card/MCard.vue +0 -78
  105. package/src/components/card/index.js +0 -7
  106. package/src/components/checkbox/MCheckboxGroup.vue +0 -155
  107. package/src/components/checkbox/index.js +0 -12
  108. package/src/components/container/MContainer.vue +0 -33
  109. package/src/components/container/index.js +0 -7
  110. package/src/components/datatable/MDataTable.vue +0 -651
  111. package/src/components/datatable/MDataTableHeader.vue +0 -55
  112. package/src/components/datatable/MDataTableTop.vue +0 -35
  113. package/src/components/datatable/helpers.js +0 -132
  114. package/src/components/datatable/index.js +0 -12
  115. package/src/components/field/index.js +0 -7
  116. package/src/components/fileuploader/MFileResult.vue +0 -149
  117. package/src/components/fileuploader/MFileUploader.vue +0 -142
  118. package/src/components/fileuploader/index.js +0 -7
  119. package/src/components/flag/MFlag.vue +0 -46
  120. package/src/components/flag/index.js +0 -7
  121. package/src/components/heading/MHeading.vue +0 -75
  122. package/src/components/heading/index.js +0 -7
  123. package/src/components/hero/MHero.vue +0 -93
  124. package/src/components/hero/index.js +0 -7
  125. package/src/components/icon/MIcon.vue +0 -120
  126. package/src/components/icon/index.js +0 -7
  127. package/src/components/index.js +0 -43
  128. package/src/components/layer/MLayer.vue +0 -208
  129. package/src/components/layer/index.js +0 -7
  130. package/src/components/link/index.js +0 -7
  131. package/src/components/listbox/MListBox.vue +0 -106
  132. package/src/components/listbox/index.js +0 -7
  133. package/src/components/loader/index.js +0 -7
  134. package/src/components/modal/MModal.vue +0 -179
  135. package/src/components/modal/index.js +0 -7
  136. package/src/components/notification/MNotification.vue +0 -110
  137. package/src/components/notification/index.js +0 -7
  138. package/src/components/optionbutton/MOptionButton.vue +0 -67
  139. package/src/components/optionbutton/index.js +0 -7
  140. package/src/components/optioncard/MOptionCard.vue +0 -132
  141. package/src/components/optioncard/index.js +0 -7
  142. package/src/components/optiongroup/MOptionGroup.vue +0 -18
  143. package/src/components/optiongroup/index.js +0 -7
  144. package/src/components/overlay/MOverlayLoader.vue +0 -43
  145. package/src/components/overlay/index.js +0 -12
  146. package/src/components/pagination/MPagination.vue +0 -162
  147. package/src/components/pagination/index.js +0 -7
  148. package/src/components/passwordinput/index.js +0 -7
  149. package/src/components/phonenumber/MPhoneNumber.vue +0 -390
  150. package/src/components/phonenumber/index.js +0 -7
  151. package/src/components/progressbar/MProgress.vue +0 -102
  152. package/src/components/progressbar/index.js +0 -7
  153. package/src/components/quantityselector/index.js +0 -7
  154. package/src/components/radio/MRadioGroup.vue +0 -111
  155. package/src/components/radio/index.js +0 -12
  156. package/src/components/ratingstars/MStarsInput.vue +0 -118
  157. package/src/components/ratingstars/MStarsResult.vue +0 -89
  158. package/src/components/ratingstars/index.js +0 -12
  159. package/src/components/select/index.js +0 -7
  160. package/src/components/stepper/MStepper.vue +0 -70
  161. package/src/components/stepper/index.js +0 -7
  162. package/src/components/tabs/MTab.vue +0 -184
  163. package/src/components/tabs/index.js +0 -7
  164. package/src/components/tags/MTag.vue +0 -173
  165. package/src/components/tags/index.js +0 -7
  166. package/src/components/textarea/index.js +0 -7
  167. package/src/components/textinput/MTextInputField.vue +0 -105
  168. package/src/components/textinput/MTextInputIcon.vue +0 -42
  169. package/src/components/textinput/index.js +0 -7
  170. package/src/components/toggle/index.js +0 -7
  171. package/src/components/tooltip/MTooltip.vue +0 -42
  172. package/src/components/tooltip/index.js +0 -7
  173. package/src/index.js +0 -62
  174. package/src/shims-tsx.d.ts +0 -13
  175. package/src/shims.vue.d.ts +0 -4
  176. package/src/tokens/adeo/android/colors.xml +0 -391
  177. package/src/tokens/adeo/android/font_dimens.xml +0 -18
  178. package/src/tokens/adeo/css/_variables.scss +0 -385
  179. package/src/tokens/adeo/css/root.scss +0 -387
  180. package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -399
  181. package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -411
  182. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -394
  183. package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
  184. package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
  185. package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
  186. package/src/tokens/adeo/js/tokens.js +0 -483
  187. package/src/tokens/adeo/js/tokensObject.js +0 -10354
  188. package/src/tokens/adeo/scss/_tokens.scss +0 -1300
  189. package/src/utils/mozaicClasses.js +0 -16
  190. package/src/utils/theme.validator.js +0 -19
  191. package/types/index.d.ts +0 -100
@@ -1,111 +0,0 @@
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-radio
21
- v-for="option in options"
22
- :id="option.id ? option.id : option.value"
23
- :key="option.id ? option.id : option.value"
24
- :is-invalid="isInvalid"
25
- :label="option.label"
26
- :name="option.name"
27
- root-class="mc-field__item"
28
- :checked="value === option.value"
29
- @change="(v) => (v ? $emit('input', option.value) : null)"
30
- />
31
- </div>
32
- <span v-if="isInvalid" :id="errorId" class="mc-field__error-message">
33
- {{ errorMessage }}
34
- </span>
35
- </fieldset>
36
- </template>
37
-
38
- <script>
39
- import MRadio from './MRadio.vue';
40
-
41
- export default {
42
- name: 'MRadioGroup',
43
-
44
- components: {
45
- MRadio,
46
- },
47
-
48
- props: {
49
- legend: {
50
- type: String,
51
- required: true,
52
- },
53
- requirementText: {
54
- type: String,
55
- default: null,
56
- },
57
- helpId: {
58
- type: String,
59
- default: null,
60
- },
61
- helpText: {
62
- type: String,
63
- default: null,
64
- },
65
- errorId: {
66
- type: String,
67
- default: null,
68
- },
69
- errorMessage: {
70
- type: String,
71
- default: null,
72
- },
73
- isInvalid: {
74
- type: Boolean,
75
- default: false,
76
- },
77
- inline: {
78
- type: Boolean,
79
- default: false,
80
- },
81
-
82
- value: {
83
- type: String,
84
- default: null,
85
- },
86
-
87
- options: {
88
- type: Array,
89
- default() {
90
- return [];
91
- },
92
- validator(options) {
93
- return options.every(
94
- (o) =>
95
- 'id' in o &&
96
- typeof o.id == 'string' &&
97
- 'label' in o &&
98
- typeof o.label == 'string' &&
99
- 'value' in o &&
100
- typeof o.value == 'string'
101
- );
102
- },
103
- },
104
- },
105
- };
106
- </script>
107
-
108
- <style lang="scss">
109
- @import 'settings-tools/_all-settings';
110
- @import 'components/_c.fields';
111
- </style>
@@ -1,12 +0,0 @@
1
- import MRadio from './MRadio.vue';
2
- import MRadioGroup from './MRadioGroup.vue';
3
-
4
- MRadio.install = function (Vue) {
5
- Vue.component(MRadio.name, MRadio);
6
- };
7
-
8
- MRadioGroup.install = function (Vue) {
9
- Vue.component(MRadioGroup.name, MRadioGroup);
10
- };
11
-
12
- export { MRadio, MRadioGroup };
@@ -1,118 +0,0 @@
1
- <template>
2
- <div :class="['mc-stars-input', setClasses]">
3
- <input
4
- :id="name + '0'"
5
- type="radio"
6
- :name="required ? name + '-unselected' : name"
7
- value="0"
8
- class="mc-stars-input__radio"
9
- checked
10
- :aria-label="unselectedText"
11
- />
12
-
13
- <template v-for="(rateId, index) in ratingValue">
14
- <input
15
- :id="name + rateId"
16
- :key="'ratingInput-' + rateId"
17
- type="radio"
18
- :name="name"
19
- :value="rateId"
20
- class="mc-stars-input__radio"
21
- :required="required"
22
- />
23
-
24
- <label
25
- :key="'ratingLabel-' + rateId"
26
- :for="name + rateId"
27
- :title="ratingLabels[index]"
28
- class="mc-stars-input__label"
29
- >
30
- <span class="mc-stars-input__text">
31
- {{ ratingLabels[index] }}
32
- </span>
33
- </label>
34
- </template>
35
- </div>
36
- </template>
37
-
38
- <script>
39
- import {
40
- responsiveModifiers,
41
- responsiveModifierValidators,
42
- } from '../../utils/mozaicClasses';
43
-
44
- const RATINGVALUE = 5;
45
-
46
- export default {
47
- name: 'MStarsInput',
48
-
49
- inheritAttrs: false,
50
-
51
- props: {
52
- unselectedText: {
53
- type: String,
54
- default: 'No opinion given',
55
- },
56
- name: {
57
- type: String,
58
- default: 'rating',
59
- },
60
- size: {
61
- type: String,
62
- default: 'm',
63
- validator: (value) =>
64
- responsiveModifierValidators(value, ['s', 'm', 'l', 'xl']),
65
- },
66
- ratingLabels: {
67
- type: Array,
68
- default() {
69
- return ['Very bad', 'Bad', 'Medium', 'Good', 'Excellent'];
70
- },
71
- validator: function (value) {
72
- return (
73
- value.length === RATINGVALUE &&
74
- value.every((item) => typeof item === 'string')
75
- );
76
- },
77
- },
78
- required: {
79
- type: Boolean,
80
- default: false,
81
- },
82
- },
83
-
84
- data() {
85
- return {
86
- id: null,
87
- ratingValue: RATINGVALUE,
88
- };
89
- },
90
-
91
- computed: {
92
- setClasses() {
93
- const classes = [];
94
-
95
- if (this.size) {
96
- responsiveModifiers('mc-stars-input', this.size, classes);
97
- }
98
-
99
- return classes;
100
- },
101
- },
102
-
103
- created() {
104
- this.id = this._uid;
105
- },
106
-
107
- methods: {
108
- incIndex(index) {
109
- return index++;
110
- },
111
- },
112
- };
113
- </script>
114
-
115
- <style lang="scss">
116
- @import 'settings-tools/_all-settings';
117
- @import 'components/_c.stars-input';
118
- </style>
@@ -1,89 +0,0 @@
1
- <template>
2
- <div :class="['mc-stars-result', setClasses]">
3
- <span class="mc-stars-result__visual" />
4
- <span class="mc-stars-result__text">
5
- {{ scoreLabel }}: {{ closestScore }}/{{ ratingValue }}
6
- </span>
7
- </div>
8
- </template>
9
-
10
- <script>
11
- import {
12
- responsiveModifiers,
13
- responsiveModifierValidators,
14
- } from '../../utils/mozaicClasses';
15
-
16
- const RATINGVALUE = 5;
17
-
18
- export default {
19
- name: 'MStarsResult',
20
-
21
- props: {
22
- score: {
23
- type: Number,
24
- default: 0,
25
- validator: (value) => value > 0 && value <= 5,
26
- },
27
- scoreLabel: {
28
- type: String,
29
- default: 'Global score',
30
- },
31
- size: {
32
- type: String,
33
- default: 'm',
34
- validator: (value) =>
35
- responsiveModifierValidators(value, ['s', 'm', 'l', 'xl']),
36
- },
37
- },
38
-
39
- data() {
40
- return {
41
- id: null,
42
- ratingValue: RATINGVALUE,
43
- };
44
- },
45
- computed: {
46
- authorizedValues() {
47
- const authorizedValue = [];
48
- for (let i = 0; i <= RATINGVALUE; i += 0.5) {
49
- authorizedValue.push(i);
50
- }
51
- return authorizedValue;
52
- },
53
- closestScore() {
54
- if (this.score > 0 && this.score <= this.ratingValue) {
55
- return this.authorizedValues.reduce((a, b) => {
56
- return Math.abs(b - this.score) < Math.abs(a - this.score) ? b : a;
57
- });
58
- } else {
59
- return 0;
60
- }
61
- },
62
- setClasses() {
63
- const classes = [];
64
-
65
- if (this.size) {
66
- responsiveModifiers('mc-stars-result', this.size, classes);
67
- }
68
-
69
- if (this.closestScore) {
70
- const classNote = `score-${
71
- (this.closestScore * 100) / this.ratingValue
72
- }`;
73
- responsiveModifiers('mc-stars-result', classNote, classes);
74
- }
75
-
76
- return classes;
77
- },
78
- },
79
-
80
- created() {
81
- this.id = this._uid;
82
- },
83
- };
84
- </script>
85
-
86
- <style lang="scss">
87
- @import 'settings-tools/_all-settings';
88
- @import 'components/_c.stars-result';
89
- </style>
@@ -1,12 +0,0 @@
1
- import MStarsInput from './MStarsInput.vue';
2
- import MStarsResult from './MStarsResult.vue';
3
-
4
- MStarsInput.install = function (Vue) {
5
- Vue.component(MStarsInput.name, MStarsInput);
6
- };
7
-
8
- MStarsResult.install = function (Vue) {
9
- Vue.component(MStarsResult.name, MStarsResult);
10
- };
11
-
12
- export { MStarsInput, MStarsResult };
@@ -1,7 +0,0 @@
1
- import MSelect from './MSelect.vue';
2
-
3
- MSelect.install = function (Vue) {
4
- Vue.component(MSelect.name, MSelect);
5
- };
6
-
7
- export { MSelect };
@@ -1,70 +0,0 @@
1
- <template>
2
- <nav class='mc-stepper' :class="{ 'mc-stepper--compact': compact, 'mc-stepper--shrinked': steps.length > 3}"
3
- :aria-label='accessibilityLabels.stepperDescription'>
4
- <ol class='mc-stepper__list'>
5
- <li
6
- v-for='(step, idx) in steps'
7
- :key='`mc-stepper__item-${idx}`'
8
- class='mc-stepper__item'
9
- :class="{
10
- 'mc-stepper__item--validated': isStepValidated(idx),
11
- 'mc-stepper__item--current': step.isCurrent,
12
- }"
13
- :aria-current="step.isCurrent ? 'step' : false"
14
- :aria-label='stepDescription(step,idx)'
15
- :style='`--steps: ${ steps.length }; --current: ${ idx +1 };`'
16
- @click="isStepValidated(idx) && $emit('step-changed', step)"
17
- >
18
- <div class='mc-stepper__indicator' aria-hidden='true'>
19
- <m-icon v-if='isStepValidated(idx)' name='NotificationAvailable16' class='mc-stepper__icon' />
20
- <span v-else-if='step.isCurrent'>{{ idx + 1 }}</span>
21
- </div>
22
- <div class='mc-stepper__detail'>
23
- <span class='mc-stepper__title'>{{ idx + 1 }} / {{ steps.length }}</span>
24
- <span class='mc-stepper__label'>{{ step.label }}</span>
25
- </div>
26
- </li>
27
- </ol>
28
- </nav>
29
- </template>
30
-
31
- <script>
32
- import MIcon from '../icon/MIcon.vue';
33
-
34
- export default {
35
- name: 'MStepper',
36
- components: {
37
- MIcon
38
- },
39
- props: {
40
- steps: {
41
- type: Array,
42
- required: true
43
- },
44
- compact: {
45
- type: Boolean,
46
- default: false
47
- },
48
- accessibilityLabels: {
49
- type: Object,
50
- required: true
51
- }
52
- },
53
- methods: {
54
- isStepValidated(index) {
55
- return index < this.steps.findIndex(step => step.isCurrent);
56
- },
57
- stepDescription(step, index) {
58
- return '#' + (index + 1) + ' ' + step.label + ', ' + this.stepStateLabel(step,index);
59
- },
60
- stepStateLabel(step, index) {
61
- return this.isStepValidated(index) ? this.accessibilityLabels.validatedLabel : step.isCurrent ? this.accessibilityLabels.currentLabel : this.accessibilityLabels.disabledLabel;
62
- }
63
- }
64
- };
65
- </script>
66
-
67
- <style lang='scss' scoped>
68
- @import 'settings-tools/_all-settings';
69
- @import 'components/_c.stepper';
70
- </style>
@@ -1,7 +0,0 @@
1
- import MStepper from './MStepper.vue';
2
-
3
- MStepper.install = function (Vue) {
4
- Vue.component(MStepper.name, MStepper);
5
- };
6
-
7
- export { MStepper };
@@ -1,184 +0,0 @@
1
- <template>
2
- <div :class="['mc-tabs', setClasses]">
3
- <ul
4
- v-if="type !== 'dropdown'"
5
- ref="tablist"
6
- class="mc-tabs__nav"
7
- role="tablist"
8
- :aria-label="description"
9
- >
10
- <li
11
- v-for="(tab, index) in tabs"
12
- :key="`tab-${index}`"
13
- class="mc-tabs__item"
14
- role="presentation"
15
- >
16
- <component
17
- :is="tab.href ? (tab.disabled ? 'span' : 'a') : 'button'"
18
- :id="tab.id"
19
- ref="tab"
20
- :href="tab.href ? (!tab.disabled ? tab.href : null) : null"
21
- :type="!tab.href ? 'button' : null"
22
- :disabled="!tab.href && tab.disabled ? true : null"
23
- class="mc-tabs__link"
24
- role="tab"
25
- :aria-selected="tab.active ? 'true' : 'false'"
26
- :class="setActiveClass(tab)"
27
- @click="
28
- manageTabs(
29
- $event.target,
30
- $event,
31
- Object.assign({ index: index }, tab)
32
- )
33
- "
34
- >
35
- {{ tab.text }}
36
- </component>
37
- </li>
38
- </ul>
39
- <m-select v-else v-bind="selectAttributes" :options="tabs" />
40
- </div>
41
- </template>
42
-
43
- <script>
44
- import MSelect from '../select/MSelect.vue';
45
-
46
- export default {
47
- name: 'MTab',
48
-
49
- components: {
50
- MSelect,
51
- },
52
-
53
- props: {
54
- tabs: {
55
- type: Array,
56
- required: true,
57
- default() {
58
- return [];
59
- },
60
- },
61
- type: {
62
- type: String,
63
- default: 'tabs',
64
- validator: (value) => ['tabs', 'dropdown'].includes(value),
65
- },
66
- description: {
67
- type: String,
68
- default: 'Tabs',
69
- },
70
- align: {
71
- type: String,
72
- default: 'auto',
73
- validator: (value) => ['auto', 'full', 'centered'].includes(value),
74
- },
75
- shadow: {
76
- type: Boolean,
77
- default: true,
78
- },
79
- selectAttributes: {
80
- type: Object,
81
- default: null,
82
- },
83
- activeIndex: {
84
- type: Number,
85
- default: 0,
86
- },
87
- },
88
-
89
- data() {
90
- return {
91
- tablist: null,
92
- };
93
- },
94
-
95
- computed: {
96
- setClasses() {
97
- const classes = [
98
- {
99
- 'mc-tabs--full': this.align === 'full',
100
- 'mc-tabs--full-centered': this.align === 'centered',
101
- 'mc-tabs--dropdown': this.type === 'dropdown',
102
- 'mc-tabs--no-shadow': !this.shadow,
103
- },
104
- ];
105
-
106
- return classes;
107
- },
108
- },
109
-
110
- watch: {
111
- activeIndex(newValue) {
112
- const tab = this.getTabFromIndex(newValue);
113
- if (tab && this.tabs[newValue]) {
114
- this.manageTabs(tab, null, Object.assign({index: newValue}, this.tabs[newValue]));
115
- }
116
- }
117
- },
118
-
119
- mounted: function () {
120
- this.$nextTick(() => {
121
- if (this.type === 'tabs') {
122
- this.tablist = this.$refs.tablist;
123
-
124
- if (this.activeIndex) {
125
- const tab = this.getTabFromIndex(this.activeIndex);
126
- if (tab) {
127
- this.manageTabs(tab);
128
- }
129
- } else {
130
- const isActive = this.tabs.some((tab) =>
131
- Object.prototype.hasOwnProperty.call(tab, 'active')
132
- );
133
- if (!isActive) {
134
- const firstTab = this.tablist.querySelector('.mc-tabs__link');
135
- this.manageTabs(firstTab);
136
- }
137
- }
138
- }
139
- });
140
- },
141
-
142
- methods: {
143
- setActiveClass: function (tab) {
144
- const tabClasses = [];
145
-
146
- if (tab.active) {
147
- tabClasses.push('mc-tabs__link--selected');
148
- }
149
-
150
- if (tab.disabled) {
151
- tabClasses.push('mc-tabs__link--disabled');
152
- }
153
-
154
- return tabClasses;
155
- },
156
- manageTabs: function (el, e, tab) {
157
- if (tab && tab.disabled) {
158
- return;
159
- }
160
- if (e) {
161
- this.$emit('tab-clicked', e.target, tab);
162
- }
163
-
164
- this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
165
- el.classList.remove('mc-tabs__link--selected');
166
- el.setAttribute('aria-selected', 'false');
167
- });
168
-
169
- el.classList.add('mc-tabs__link--selected');
170
- el.setAttribute('aria-selected', 'true');
171
- },
172
- getTabFromIndex: function (index) {
173
- if (this.tablist && this.tablist.children[index] && this.tablist.children[index].children[0]) {
174
- return this.tablist.children[index].children[0];
175
- }
176
- },
177
- },
178
- };
179
- </script>
180
-
181
- <style lang="scss">
182
- @import 'settings-tools/_all-settings';
183
- @import 'components/_c.tabs';
184
- </style>
@@ -1,7 +0,0 @@
1
- import MTab from './MTab.vue';
2
-
3
- MTab.install = function (Vue) {
4
- Vue.component(MTab.name, MTab);
5
- };
6
-
7
- export { MTab };