@mozaic-ds/vue 1.0.0-rc.3 → 2.1.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 (222) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +76 -77
  3. package/dist/mozaic-vue.css +1 -1
  4. package/dist/mozaic-vue.d.ts +1664 -0
  5. package/dist/mozaic-vue.js +1943 -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 +78 -51
  11. package/src/components/Contributing.mdx +118 -0
  12. package/src/components/GettingStarted.mdx +45 -0
  13. package/src/components/Introduction.mdx +100 -0
  14. package/src/components/Support.mdx +18 -0
  15. package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
  16. package/src/components/breadcrumb/MBreadcrumb.stories.ts +82 -0
  17. package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
  18. package/src/components/button/MButton.spec.ts +191 -0
  19. package/src/components/button/MButton.stories.ts +59 -0
  20. package/src/components/button/MButton.vue +98 -154
  21. package/src/components/checkbox/MCheckbox.spec.ts +104 -0
  22. package/src/components/checkbox/MCheckbox.stories.ts +83 -0
  23. package/src/components/checkbox/MCheckbox.vue +60 -101
  24. package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
  25. package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
  26. package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
  27. package/src/components/datepicker/MDatepicker.spec.ts +95 -0
  28. package/src/components/datepicker/MDatepicker.stories.ts +75 -0
  29. package/src/components/datepicker/MDatepicker.vue +114 -0
  30. package/src/components/divider/MDivider.spec.ts +57 -0
  31. package/src/components/divider/MDivider.stories.ts +64 -0
  32. package/src/components/divider/MDivider.vue +56 -0
  33. package/src/components/drawer/MDrawer.spec.ts +100 -0
  34. package/src/components/drawer/MDrawer.stories.ts +128 -0
  35. package/src/components/drawer/MDrawer.vue +140 -0
  36. package/src/components/field/MField.spec.ts +166 -0
  37. package/src/components/field/MField.stories.ts +369 -0
  38. package/src/components/field/MField.vue +78 -61
  39. package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
  40. package/src/components/fieldgroup/MFieldGroup.stories.ts +416 -0
  41. package/src/components/fieldgroup/MFieldGroup.vue +79 -0
  42. package/src/components/flag/MFlag.spec.ts +46 -0
  43. package/src/components/flag/MFlag.stories.ts +46 -0
  44. package/src/components/flag/MFlag.vue +28 -39
  45. package/src/components/iconbutton/MIconButton.spec.ts +108 -0
  46. package/src/components/iconbutton/MIconButton.stories.ts +74 -0
  47. package/src/components/iconbutton/MIconButton.vue +73 -0
  48. package/src/components/link/MLink.spec.ts +154 -0
  49. package/src/components/link/MLink.stories.ts +89 -0
  50. package/src/components/link/MLink.vue +86 -120
  51. package/src/components/loader/MLoader.spec.ts +104 -0
  52. package/src/components/loader/MLoader.stories.ts +43 -0
  53. package/src/components/loader/MLoader.vue +66 -55
  54. package/src/components/loadingoverlay/MLoadingOverlay.spec.ts +37 -0
  55. package/src/components/loadingoverlay/MLoadingOverlay.stories.ts +40 -0
  56. package/src/components/loadingoverlay/MLoadingOverlay.vue +28 -0
  57. package/src/components/modal/MModal.spec.ts +103 -0
  58. package/src/components/modal/MModal.stories.ts +127 -0
  59. package/src/components/modal/MModal.vue +111 -159
  60. package/src/components/numberbadge/MNumberBadge.spec.ts +56 -0
  61. package/src/components/numberbadge/MNumberBadge.stories.ts +48 -0
  62. package/src/components/numberbadge/MNumberBadge.vue +45 -0
  63. package/src/components/overlay/MOverlay.spec.ts +51 -0
  64. package/src/components/overlay/MOverlay.stories.ts +35 -0
  65. package/src/components/overlay/MOverlay.vue +27 -19
  66. package/src/components/pagination/MPagination.spec.ts +123 -0
  67. package/src/components/pagination/MPagination.stories.ts +83 -0
  68. package/src/components/pagination/MPagination.vue +120 -140
  69. package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
  70. package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
  71. package/src/components/passwordinput/MPasswordInput.vue +126 -77
  72. package/src/components/pincode/MPincode.spec.ts +126 -0
  73. package/src/components/pincode/MPincode.stories.ts +68 -0
  74. package/src/components/pincode/MPincode.vue +148 -0
  75. package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
  76. package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
  77. package/src/components/quantityselector/MQuantitySelector.vue +159 -148
  78. package/src/components/radio/MRadio.spec.ts +104 -0
  79. package/src/components/radio/MRadio.stories.ts +68 -0
  80. package/src/components/radio/MRadio.vue +56 -39
  81. package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
  82. package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
  83. package/src/components/radiogroup/MRadioGroup.vue +79 -0
  84. package/src/components/select/MSelect.spec.ts +114 -0
  85. package/src/components/select/MSelect.stories.ts +101 -0
  86. package/src/components/select/MSelect.vue +77 -119
  87. package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
  88. package/src/components/statusbadge/MStatusBadge.vue +40 -0
  89. package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
  90. package/src/components/statusdot/MStatusDot.spec.ts +51 -0
  91. package/src/components/statusdot/MStatusDot.stories.ts +48 -0
  92. package/src/components/statusdot/MStatusDot.vue +36 -0
  93. package/src/components/statusnotification/MStatusNotification.spec.ts +103 -0
  94. package/src/components/statusnotification/MStatusNotification.stories.ts +89 -0
  95. package/src/components/statusnotification/MStatusNotification.vue +106 -0
  96. package/src/components/tabs/MTabs.stories.ts +104 -0
  97. package/src/components/tabs/MTabs.vue +113 -0
  98. package/src/components/tabs/Mtabs.spec.ts +149 -0
  99. package/src/components/tag/MTag.spec.ts +107 -0
  100. package/src/components/tag/MTag.stories.ts +75 -0
  101. package/src/components/tag/MTag.vue +151 -0
  102. package/src/components/textarea/MTextArea.spec.ts +112 -0
  103. package/src/components/textarea/MTextArea.stories.ts +67 -0
  104. package/src/components/textarea/MTextArea.vue +81 -43
  105. package/src/components/textinput/MTextInput.spec.ts +121 -0
  106. package/src/components/textinput/MTextInput.stories.ts +107 -0
  107. package/src/components/textinput/MTextInput.vue +127 -47
  108. package/src/components/toggle/MToggle.spec.ts +99 -0
  109. package/src/components/toggle/MToggle.stories.ts +68 -0
  110. package/src/components/toggle/MToggle.vue +63 -103
  111. package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
  112. package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
  113. package/src/components/togglegroup/MToggleGroup.vue +97 -0
  114. package/src/components/usingIcons.mdx +35 -0
  115. package/src/components/usingPresets.mdx +128 -0
  116. package/src/main.ts +32 -0
  117. package/dist/demo.html +0 -1
  118. package/dist/mozaic-vue.adeo.css +0 -47
  119. package/dist/mozaic-vue.adeo.umd.js +0 -31341
  120. package/dist/mozaic-vue.common.js +0 -31331
  121. package/dist/mozaic-vue.common.js.map +0 -1
  122. package/dist/mozaic-vue.umd.js +0 -31342
  123. package/dist/mozaic-vue.umd.js.map +0 -1
  124. package/dist/mozaic-vue.umd.min.js +0 -4
  125. package/dist/mozaic-vue.umd.min.js.map +0 -1
  126. package/postinstall.js +0 -3
  127. package/src/components/accordion/MAccordion.vue +0 -128
  128. package/src/components/accordion/index.js +0 -7
  129. package/src/components/autocomplete/MAutocomplete.vue +0 -380
  130. package/src/components/autocomplete/index.js +0 -7
  131. package/src/components/badge/MBadge.vue +0 -43
  132. package/src/components/badge/index.js +0 -7
  133. package/src/components/breadcrumb/index.js +0 -7
  134. package/src/components/button/index.js +0 -7
  135. package/src/components/card/MCard.vue +0 -78
  136. package/src/components/card/index.js +0 -7
  137. package/src/components/checkbox/MCheckboxGroup.vue +0 -163
  138. package/src/components/checkbox/index.js +0 -12
  139. package/src/components/container/MContainer.vue +0 -33
  140. package/src/components/container/index.js +0 -7
  141. package/src/components/datatable/MDataTable.vue +0 -651
  142. package/src/components/datatable/MDataTableHeader.vue +0 -55
  143. package/src/components/datatable/MDataTableTop.vue +0 -35
  144. package/src/components/datatable/helpers.js +0 -132
  145. package/src/components/datatable/index.js +0 -12
  146. package/src/components/dropdown/MDropdown.vue +0 -317
  147. package/src/components/dropdown/index.js +0 -7
  148. package/src/components/field/index.js +0 -7
  149. package/src/components/fileuploader/MFileResult.vue +0 -149
  150. package/src/components/fileuploader/MFileUploader.vue +0 -142
  151. package/src/components/fileuploader/index.js +0 -7
  152. package/src/components/flag/index.js +0 -7
  153. package/src/components/heading/MHeading.vue +0 -75
  154. package/src/components/heading/index.js +0 -7
  155. package/src/components/hero/MHero.vue +0 -93
  156. package/src/components/hero/index.js +0 -7
  157. package/src/components/icon/MIcon.vue +0 -136
  158. package/src/components/icon/index.js +0 -7
  159. package/src/components/index.js +0 -44
  160. package/src/components/layer/MLayer.vue +0 -208
  161. package/src/components/layer/index.js +0 -7
  162. package/src/components/link/index.js +0 -7
  163. package/src/components/listbox/MListBox.vue +0 -146
  164. package/src/components/listbox/MListBoxActions.vue +0 -251
  165. package/src/components/listbox/index.js +0 -12
  166. package/src/components/loader/index.js +0 -7
  167. package/src/components/modal/index.js +0 -7
  168. package/src/components/notification/MNotification.vue +0 -110
  169. package/src/components/notification/index.js +0 -7
  170. package/src/components/optionbutton/MOptionButton.vue +0 -67
  171. package/src/components/optionbutton/index.js +0 -7
  172. package/src/components/optioncard/MOptionCard.vue +0 -132
  173. package/src/components/optioncard/index.js +0 -7
  174. package/src/components/optiongroup/MOptionGroup.vue +0 -18
  175. package/src/components/optiongroup/index.js +0 -7
  176. package/src/components/overlay/MOverlayLoader.vue +0 -43
  177. package/src/components/overlay/index.js +0 -12
  178. package/src/components/pagination/index.js +0 -7
  179. package/src/components/passwordinput/index.js +0 -7
  180. package/src/components/phonenumber/MPhoneNumber.vue +0 -398
  181. package/src/components/phonenumber/index.js +0 -7
  182. package/src/components/progressbar/MProgress.vue +0 -102
  183. package/src/components/progressbar/index.js +0 -7
  184. package/src/components/quantityselector/index.js +0 -7
  185. package/src/components/radio/MRadioGroup.vue +0 -111
  186. package/src/components/radio/index.js +0 -12
  187. package/src/components/ratingstars/MStarsInput.vue +0 -119
  188. package/src/components/ratingstars/MStarsResult.vue +0 -89
  189. package/src/components/ratingstars/index.js +0 -12
  190. package/src/components/select/index.js +0 -7
  191. package/src/components/stepper/MStepper.vue +0 -111
  192. package/src/components/stepper/index.js +0 -7
  193. package/src/components/tabs/MTab.vue +0 -204
  194. package/src/components/tabs/index.js +0 -7
  195. package/src/components/tags/MTag.vue +0 -175
  196. package/src/components/tags/index.js +0 -7
  197. package/src/components/textarea/index.js +0 -7
  198. package/src/components/textinput/MTextInputField.vue +0 -105
  199. package/src/components/textinput/MTextInputIcon.vue +0 -42
  200. package/src/components/textinput/index.js +0 -7
  201. package/src/components/toggle/index.js +0 -7
  202. package/src/components/tooltip/MTooltip.vue +0 -42
  203. package/src/components/tooltip/index.js +0 -7
  204. package/src/index.js +0 -63
  205. package/src/shims-tsx.d.ts +0 -13
  206. package/src/shims.vue.d.ts +0 -4
  207. package/src/tokens/adeo/android/colors.xml +0 -452
  208. package/src/tokens/adeo/android/font_dimens.xml +0 -18
  209. package/src/tokens/adeo/css/_variables.scss +0 -446
  210. package/src/tokens/adeo/css/root.scss +0 -448
  211. package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -460
  212. package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -472
  213. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -455
  214. package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
  215. package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
  216. package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
  217. package/src/tokens/adeo/js/tokens.js +0 -544
  218. package/src/tokens/adeo/js/tokensObject.js +0 -11733
  219. package/src/tokens/adeo/scss/_tokens.scss +0 -1522
  220. package/src/utils/mozaicClasses.js +0 -16
  221. package/src/utils/theme.validator.js +0 -19
  222. package/types/index.d.ts +0 -104
@@ -1,119 +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
- @click="$emit('star-clicked', index + 1)"
23
- />
24
-
25
- <label
26
- :key="'ratingLabel-' + rateId"
27
- :for="name + rateId"
28
- :title="ratingLabels[index]"
29
- class="mc-stars-input__label"
30
- >
31
- <span class="mc-stars-input__text">
32
- {{ ratingLabels[index] }}
33
- </span>
34
- </label>
35
- </template>
36
- </div>
37
- </template>
38
-
39
- <script>
40
- import {
41
- responsiveModifiers,
42
- responsiveModifierValidators,
43
- } from '../../utils/mozaicClasses';
44
-
45
- const RATINGVALUE = 5;
46
-
47
- export default {
48
- name: 'MStarsInput',
49
-
50
- inheritAttrs: false,
51
-
52
- props: {
53
- unselectedText: {
54
- type: String,
55
- default: 'No opinion given',
56
- },
57
- name: {
58
- type: String,
59
- default: 'rating',
60
- },
61
- size: {
62
- type: String,
63
- default: 'm',
64
- validator: (value) =>
65
- responsiveModifierValidators(value, ['s', 'm', 'l', 'xl']),
66
- },
67
- ratingLabels: {
68
- type: Array,
69
- default() {
70
- return ['Very bad', 'Bad', 'Medium', 'Good', 'Excellent'];
71
- },
72
- validator: function (value) {
73
- return (
74
- value.length === RATINGVALUE &&
75
- value.every((item) => typeof item === 'string')
76
- );
77
- },
78
- },
79
- required: {
80
- type: Boolean,
81
- default: false,
82
- },
83
- },
84
-
85
- data() {
86
- return {
87
- id: null,
88
- ratingValue: RATINGVALUE,
89
- };
90
- },
91
-
92
- computed: {
93
- setClasses() {
94
- const classes = [];
95
-
96
- if (this.size) {
97
- responsiveModifiers('mc-stars-input', this.size, classes);
98
- }
99
-
100
- return classes;
101
- },
102
- },
103
-
104
- created() {
105
- this.id = this._uid;
106
- },
107
-
108
- methods: {
109
- incIndex(index) {
110
- return index++;
111
- },
112
- },
113
- };
114
- </script>
115
-
116
- <style lang="scss">
117
- @import 'settings-tools/_all-settings';
118
- @import 'components/_c.stars-input';
119
- </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,111 +0,0 @@
1
- <template>
2
- <nav
3
- class="mc-stepper"
4
- :class="{
5
- 'mc-stepper--compact': compact,
6
- 'mc-stepper--shrinked': steps.length > 3,
7
- }"
8
- :aria-label="accessibilityLabels.stepperDescription"
9
- >
10
- <ol class="mc-stepper__list">
11
- <li
12
- v-for="(step, idx) in steps"
13
- :key="`mc-stepper__item-${idx}`"
14
- class="mc-stepper__item"
15
- :class="{
16
- 'mc-stepper__item--validated': isStepValidated(idx),
17
- 'mc-stepper__item--current': step.isCurrent,
18
- }"
19
- :aria-current="step.isCurrent ? 'step' : false"
20
- :aria-label="stepDescription(step, idx)"
21
- :style="`--steps: ${steps.length}; --current: ${idx + 1};`"
22
- @click="isStepValidated(idx) && $emit('step-changed', step)"
23
- >
24
- <a v-if="step.href && isStepValidated(idx)" :href="step.href" class="mc-stepper__link">
25
- <div class="mc-stepper__indicator" aria-hidden="true">
26
- <m-icon
27
- v-if="isStepValidated(idx)"
28
- name="NotificationAvailable16"
29
- class="mc-stepper__icon"
30
- />
31
- <span v-else-if="step.isCurrent">{{ idx + 1 }}</span>
32
- </div>
33
- <div class="mc-stepper__detail">
34
- <span class="mc-stepper__title"
35
- >{{ idx + 1 }} / {{ steps.length }}</span
36
- >
37
- <span class="mc-stepper__label">{{ step.label }}</span>
38
- </div>
39
- </a>
40
- <template v-else>
41
- <div class="mc-stepper__indicator" aria-hidden="true">
42
- <m-icon
43
- v-if="isStepValidated(idx)"
44
- name="NotificationAvailable16"
45
- class="mc-stepper__icon"
46
- />
47
- <span v-else-if="step.isCurrent">{{ idx + 1 }}</span>
48
- </div>
49
- <div class="mc-stepper__detail">
50
- <span class="mc-stepper__title"
51
- >{{ idx + 1 }} / {{ steps.length }}</span
52
- >
53
- <span class="mc-stepper__label">{{ step.label }}</span>
54
- </div>
55
- </template>
56
- </li>
57
- </ol>
58
- </nav>
59
- </template>
60
-
61
- <script>
62
- import MIcon from '../icon/MIcon.vue';
63
-
64
- export default {
65
- name: 'MStepper',
66
- components: {
67
- MIcon,
68
- },
69
- props: {
70
- steps: {
71
- type: Array,
72
- required: true,
73
- },
74
- compact: {
75
- type: Boolean,
76
- default: false,
77
- },
78
- accessibilityLabels: {
79
- type: Object,
80
- required: true,
81
- },
82
- },
83
- methods: {
84
- isStepValidated(index) {
85
- return index < this.steps.findIndex((step) => step.isCurrent);
86
- },
87
- stepDescription(step, index) {
88
- return (
89
- '#' +
90
- (index + 1) +
91
- ' ' +
92
- step.label +
93
- ', ' +
94
- this.stepStateLabel(step, index)
95
- );
96
- },
97
- stepStateLabel(step, index) {
98
- return this.isStepValidated(index)
99
- ? this.accessibilityLabels.validatedLabel
100
- : step.isCurrent
101
- ? this.accessibilityLabels.currentLabel
102
- : this.accessibilityLabels.disabledLabel;
103
- },
104
- },
105
- };
106
- </script>
107
-
108
- <style lang="scss" scoped>
109
- @import 'settings-tools/_all-settings';
110
- @import 'components/_c.stepper';
111
- </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,204 +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.router}`"
18
- v-if="tab.router"
19
- v-bind="tab.attrs"
20
- :to="tab.to"
21
- class="mc-tabs__element"
22
- :class="setActiveClass(tab)"
23
- active-class="mc-tabs__element--selected"
24
- >
25
- <span class="mc-tabs__text">{{ tab.text }}</span>
26
- </component>
27
- <component
28
- :is="tab.href ? (tab.disabled ? 'span' : 'a') : 'button'"
29
- v-else
30
- :id="tab.id"
31
- ref="tab"
32
- :href="tab.href ? (!tab.disabled ? tab.href : null) : null"
33
- :type="!tab.href ? 'button' : null"
34
- :disabled="!tab.href && tab.disabled ? true : null"
35
- class="mc-tabs__element"
36
- role="tab"
37
- :aria-selected="tab.active ? 'true' : 'false'"
38
- :class="setActiveClass(tab)"
39
- @click="
40
- manageTabs(
41
- $event.target,
42
- $event,
43
- Object.assign({ index: index }, tab)
44
- )
45
- "
46
- >
47
- <span class="mc-tabs__text">{{ tab.text }}</span>
48
- </component>
49
- </li>
50
- </ul>
51
- <m-select v-else v-bind="selectAttributes" :options="tabs" />
52
- </div>
53
- </template>
54
-
55
- <script>
56
- import MSelect from '../select/MSelect.vue';
57
-
58
- export default {
59
- name: 'MTab',
60
-
61
- components: {
62
- MSelect,
63
- },
64
-
65
- props: {
66
- tabs: {
67
- type: Array,
68
- required: true,
69
- default() {
70
- return [];
71
- },
72
- },
73
- type: {
74
- type: String,
75
- default: 'tabs',
76
- validator: (value) => ['tabs', 'dropdown'].includes(value),
77
- },
78
- description: {
79
- type: String,
80
- default: 'Tabs',
81
- },
82
- align: {
83
- type: String,
84
- default: 'auto',
85
- validator: (value) => ['auto', 'full', 'centered'].includes(value),
86
- },
87
- shadow: {
88
- type: Boolean,
89
- default: true,
90
- },
91
- selectAttributes: {
92
- type: Object,
93
- default: null,
94
- },
95
- activeIndex: {
96
- type: Number,
97
- default: 0,
98
- },
99
- },
100
-
101
- data() {
102
- return {
103
- tablist: null,
104
- };
105
- },
106
-
107
- computed: {
108
- setClasses() {
109
- const classes = [
110
- {
111
- 'mc-tabs--full': this.align === 'full',
112
- 'mc-tabs--full-centered': this.align === 'centered',
113
- 'mc-tabs--dropdown': this.type === 'dropdown',
114
- 'mc-tabs--no-shadow': !this.shadow,
115
- },
116
- ];
117
-
118
- return classes;
119
- },
120
- },
121
-
122
- watch: {
123
- activeIndex(newValue) {
124
- const tab = this.getTabFromIndex(newValue);
125
- if (tab && this.tabs[newValue]) {
126
- this.manageTabs(
127
- tab,
128
- null,
129
- Object.assign({ index: newValue }, this.tabs[newValue])
130
- );
131
- }
132
- },
133
- },
134
-
135
- mounted: function () {
136
- this.$nextTick(() => {
137
- if (this.type === 'tabs') {
138
- this.tablist = this.$refs.tablist;
139
-
140
- if (this.activeIndex) {
141
- const tab = this.getTabFromIndex(this.activeIndex);
142
- if (tab) {
143
- this.manageTabs(tab);
144
- }
145
- } else {
146
- const isActive = this.tabs.some((tab) =>
147
- Object.prototype.hasOwnProperty.call(tab, 'active')
148
- );
149
- if (!isActive) {
150
- const firstTab = this.tablist.querySelector('.mc-tabs__element');
151
- this.manageTabs(firstTab);
152
- }
153
- }
154
- }
155
- });
156
- },
157
-
158
- methods: {
159
- setActiveClass: function (tab) {
160
- const tabClasses = [];
161
-
162
- if (tab.active) {
163
- tabClasses.push('mc-tabs__element--selected');
164
- }
165
-
166
- if (tab.disabled) {
167
- tabClasses.push('mc-tabs__element--disabled');
168
- }
169
-
170
- return tabClasses;
171
- },
172
- manageTabs: function (el, e, tab) {
173
- if (tab && tab.disabled) {
174
- return;
175
- }
176
- if (e) {
177
- this.$emit('tab-clicked', e.currentTarget, tab);
178
- }
179
-
180
- this.tablist.querySelectorAll('.mc-tabs__element').forEach((el) => {
181
- el.classList.remove('mc-tabs__element--selected');
182
- el.setAttribute('aria-selected', 'false');
183
- });
184
-
185
- el.classList.add('mc-tabs__element--selected');
186
- el.setAttribute('aria-selected', 'true');
187
- },
188
- getTabFromIndex: function (index) {
189
- if (
190
- this.tablist &&
191
- this.tablist.children[index] &&
192
- this.tablist.children[index].children[0]
193
- ) {
194
- return this.tablist.children[index].children[0];
195
- }
196
- },
197
- },
198
- };
199
- </script>
200
-
201
- <style lang="scss">
202
- @import 'settings-tools/all-settings';
203
- @import 'components/c.tabs';
204
- </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 };