@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,35 +0,0 @@
1
- <template>
2
- <div
3
- v-if="$slots.edition || $slots.actions || $slots.filters"
4
- class="mc-datatable__header"
5
- >
6
- <div class="mc-datatable__topbar">
7
- <div v-if="$slots.edition" class="mc-datatable__topbar-edition">
8
- <slot name="edition" />
9
- </div>
10
- <div v-if="$slots.actions" class="mc-datatable__topbar-actions">
11
- <slot name="actions" />
12
- </div>
13
- </div>
14
- <div v-if="$slots.filters" class="mc-datatable__filters">
15
- <slot name="filters" />
16
- </div>
17
- </div>
18
- </template>
19
-
20
- <script>
21
- export default {
22
- name: 'MDataTableTop',
23
- };
24
- </script>
25
-
26
- <style lang="scss">
27
- @import 'settings-tools/all-settings';
28
- @import 'components/c.datatable-header';
29
-
30
- .mc-datatable {
31
- &__topbar-actions {
32
- margin-left: auto;
33
- }
34
- }
35
- </style>
@@ -1,132 +0,0 @@
1
- /** create a sort function to pass into the sort function of the array.
2
- * The objective is to be able to sort on several fields ordered according to the same order as the parameter.
3
- * @example
4
- * array.sort(orderedArraySorted([{
5
- * fieldExpr: 'prop1'
6
- * },{
7
- * fieldExpr: 'prop2.propA',
8
- * sortOrder: 'desc' }]
9
- * ))
10
- * // the array is order by 'prop1', then by 'prop2.propA'.
11
- * */
12
- export function orderedArraySorted(properties) {
13
- const compareFn = function (left, right, sortOrder = 'asc') {
14
- const direction = sortOrder === 'asc' ? 1 : -1;
15
- return (left > right ? 1 : left < right ? -1 : 0) * direction;
16
- };
17
-
18
- return function (item1, item2) {
19
- return properties
20
- .map((property) => {
21
- return compareFn(
22
- getObjectValueByPath(item1, property.fieldExpr),
23
- getObjectValueByPath(item2, property.fieldExpr),
24
- property.sortOrder
25
- );
26
- })
27
- .reduceRight((left, right) => {
28
- return right || left;
29
- });
30
- };
31
- }
32
-
33
- /** Test if value is a Promise function. */
34
- export function isPromise(value) {
35
- return value.toString().includes('Promise');
36
- }
37
-
38
- /** Test if object a is equal to object b. */
39
- export function deepEqual(a, b) {
40
- if (a === b) {
41
- return true;
42
- }
43
-
44
- if (a instanceof Date && b instanceof Date && a.getTime() !== b.getTime()) {
45
- // If the values are Date, compare them as timestamps
46
- return false;
47
- }
48
-
49
- if (a !== Object(a) || b !== Object(b)) {
50
- // If the values aren't objects, they were already checked for equality
51
- return false;
52
- }
53
-
54
- const props = Object.keys(a);
55
-
56
- if (props.length !== Object.keys(b).length) {
57
- // Different number of props, don't bother to check
58
- return false;
59
- }
60
-
61
- return props.every((p) => deepEqual(a[p], b[p]));
62
- }
63
-
64
- /** Get value of an object by string path.
65
- * @example
66
- * let obj = {
67
- * prop1: {
68
- * propA: 'test'
69
- * }
70
- * }
71
- * let result = getObjectValueByPath(obj, 'prop1.propA')
72
- * // result is equal to 'test'.
73
- */
74
- export function getObjectValueByPath(obj, path) {
75
- // credit: http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key#comment55278413_6491621
76
- if (obj == null || !path || typeof path !== 'string') {
77
- return null;
78
- }
79
- if (obj[path] !== undefined) {
80
- return obj[path];
81
- }
82
- path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
83
- path = path.replace(/^\./, ''); // strip a leading dot
84
- return getNestedValue(obj, path.split('.'));
85
- }
86
-
87
- function getNestedValue(obj, path) {
88
- const last = path.length - 1;
89
-
90
- if (last < 0) {
91
- return obj;
92
- }
93
-
94
- for (let i = 0; i < last; i++) {
95
- if (obj == null) {
96
- return null;
97
- }
98
- obj = obj[path[i]];
99
- }
100
-
101
- return obj[path[last]];
102
- }
103
- /** Convert string value to unit (Default: px). */
104
- export function convertToUnit(str, unit = 'px') {
105
- if (str == null || str === '') {
106
- return undefined;
107
- } else if (isNaN(+str)) {
108
- return String(str);
109
- } else {
110
- return `${Number(str)}${unit}`;
111
- }
112
- }
113
- /** Parse value as object used by bindabled class property. */
114
- export function parseClasses(value, obj) {
115
- if (typeof value === 'function') {
116
- return parseClasses(value(obj));
117
- } else if (Array.isArray(value)) {
118
- return value.reduce(
119
- (acc, v) => ({
120
- ...acc,
121
- [v]: true,
122
- }),
123
- {}
124
- );
125
- } else if (typeof value === 'object') {
126
- return value;
127
- } else if (value != null) {
128
- return { [value]: true };
129
- } else {
130
- return null;
131
- }
132
- }
@@ -1,12 +0,0 @@
1
- import MDataTable from './MDataTable.vue';
2
- import MDataTableHeader from './MDataTableHeader.vue';
3
-
4
- MDataTable.install = function (Vue) {
5
- Vue.component(MDataTable.name, MDataTable);
6
- };
7
-
8
- MDataTableHeader.install = function (Vue) {
9
- Vue.component(MDataTableHeader.name, MDataTableHeader);
10
- };
11
-
12
- export { MDataTable, MDataTableHeader };
@@ -1,317 +0,0 @@
1
- <template>
2
- <div
3
- ref="dropdown"
4
- v-click-outside="onClickOutside"
5
- class="mc-dropdown"
6
- :class="{ 'mc-dropdown--multi': multiple }"
7
- :style="setStyles"
8
- >
9
- <MTag
10
- v-if="multiple && listboxValue.length > 0"
11
- :id="tagId ? tagId : `autoCompleteTag-${uuid}`"
12
- ref="tag"
13
- :label="setTagLabel"
14
- :disabled="disabled"
15
- type="removable"
16
- class="mc-dropdown__tag"
17
- size="s"
18
- @remove-tag="clearAutocomplete()"
19
- />
20
- <button
21
- type="button"
22
- class="mc-select mc-dropdown__trigger"
23
- :class="{ 'is-open': openState }"
24
- :disabled="disabled"
25
- @click="openState = !openState"
26
- >
27
- {{ buttonValue }}
28
- </button>
29
- <MListBox
30
- v-model="listboxValue"
31
- :open="openState"
32
- :items="localItems"
33
- :multiple="multiple"
34
- :empty-search-label="emptySearchLabel"
35
- :data-key-expr="dataKeyExpr"
36
- :data-text-expr="dataTextExpr"
37
- :data-value-expr="dataValueExpr"
38
- @change="onChange"
39
- >
40
- <template #item="{ item }">
41
- <slot name="item" :item="item"></slot>
42
- </template>
43
- </MListBox>
44
- </div>
45
- </template>
46
-
47
- <script>
48
- import MTag from '../tags/MTag.vue';
49
- import MListBox from '../listbox/MListBox.vue';
50
-
51
- export default {
52
- name: 'MDropdown',
53
-
54
- components: {
55
- MTag,
56
- MListBox,
57
- },
58
-
59
- directives: {
60
- 'click-outside': {
61
- bind(el, binding, vnode) {
62
- el.clickOutsideEvent = (event) => {
63
- if (!(el === event.target || el.contains(event.target))) {
64
- vnode.context[binding.expression](event);
65
- }
66
- };
67
- document.body.addEventListener('click', el.clickOutsideEvent);
68
- },
69
- unbind(el) {
70
- document.body.removeEventListener('click', el.clickOutsideEvent);
71
- },
72
- },
73
- },
74
-
75
- model: {
76
- event: 'change',
77
- },
78
-
79
- props: {
80
- // Tag Element
81
- tagId: {
82
- type: String,
83
- default: null,
84
- },
85
- tagLabel: {
86
- type: String,
87
- default: '',
88
- },
89
- // Input Element
90
- placeholder: {
91
- type: String,
92
- default: '-- Placeholder --',
93
- },
94
- filter: {
95
- type: Function,
96
- default: null,
97
- },
98
- disabled: {
99
- type: Boolean,
100
- default: false,
101
- },
102
- // Listbox Element
103
- items: {
104
- type: Array,
105
- required: true,
106
- },
107
- value: {
108
- type: [Array, String, Number],
109
- default: undefined,
110
- },
111
- open: {
112
- type: Boolean,
113
- default: false,
114
- },
115
- multiple: {
116
- type: Boolean,
117
- default: false,
118
- },
119
- emptySearchLabel: {
120
- type: String,
121
- default: 'No results found',
122
- },
123
- dataKeyExpr: {
124
- type: String,
125
- default: 'id',
126
- },
127
- dataTextExpr: {
128
- type: String,
129
- default: 'label',
130
- },
131
- dataValueExpr: {
132
- type: String,
133
- default: 'value',
134
- },
135
- sort: {
136
- type: Boolean,
137
- default: true,
138
- },
139
- // Global
140
- maxWidth: {
141
- type: String,
142
- default: '17.875rem',
143
- },
144
- },
145
-
146
- data() {
147
- return {
148
- uuid: Math.random(),
149
- openState: this.open,
150
- tagWidth: '0px',
151
- tagValue: null,
152
- buttonValue: this.placeholder,
153
- localItems: null,
154
- sortedListItems: null,
155
- listboxValue: null,
156
- };
157
- },
158
-
159
- computed: {
160
- setTagLabel() {
161
- return this.listboxValue.length.toString() + ' ' + this.tagLabel;
162
- },
163
- setStyles() {
164
- return {
165
- '--tag-width': this.tagWidth,
166
- '--max-width': this.maxWidth,
167
- };
168
- },
169
- },
170
-
171
- watch: {
172
- value: {
173
- handler: function (val) {
174
- if (!val && this.multiple) {
175
- this.listboxValue = [];
176
- } else {
177
- this.listboxValue = val;
178
- }
179
- },
180
- immediate: true,
181
- },
182
-
183
- items: {
184
- handler: function (val) {
185
- this.localItems = val;
186
- // this.clearAutocomplete();
187
- },
188
- immediate: true,
189
- },
190
-
191
- listboxValue: function (val) {
192
- const value = Array.isArray(val) ? val : val.toString();
193
- const selectedItems = this.getSelectedItems(value);
194
-
195
- const seletedLabels = selectedItems.map(
196
- (item) => item[this.dataTextExpr]
197
- );
198
-
199
- this.buttonValue = seletedLabels.join(', ');
200
-
201
- if (val.length === 0) {
202
- this.buttonValue = this.placeholder;
203
- }
204
-
205
- if (this.multiple) {
206
- this.tagValue = val;
207
- }
208
- },
209
-
210
- tagValue: function () {
211
- this.setTagWidth();
212
- },
213
-
214
- openState: function (val) {
215
- const eventName = val ? 'open' : 'close';
216
- this.$emit(eventName);
217
- this.$emit('update:open', val);
218
- },
219
- },
220
-
221
- methods: {
222
- setTagWidth() {
223
- this.$nextTick(() => {
224
- if (this.$refs.tag && this.$refs.tag.$el) {
225
- this.tagWidth = this.$refs.tag.$el.clientWidth + 8 + 'px';
226
- } else {
227
- this.tagWidth = '0px';
228
- }
229
- });
230
- },
231
-
232
- clearAutocomplete() {
233
- this.listboxValue = this.multiple ? [] : undefined;
234
- this.onChange();
235
- this.$emit('clear');
236
- },
237
-
238
- onClickOutside() {
239
- this.openState = false;
240
-
241
- if (this.multiple && this.sort) {
242
- this.sortItems();
243
- } else {
244
- this.localItems = this.items;
245
- }
246
- },
247
-
248
- onChange() {
249
- this.$emit('change', this.listboxValue);
250
-
251
- if (!this.multiple) {
252
- this.onClickOutside();
253
- }
254
- },
255
-
256
- getSelectedItems(val) {
257
- const value = val ? val : this.listboxValue;
258
-
259
- const selectedItems = this.items.filter((item) =>
260
- value.includes(item[this.dataValueExpr])
261
- );
262
-
263
- return selectedItems;
264
- },
265
-
266
- sortItems() {
267
- this.sortedListItems = this.items;
268
- const selectedItems = this.getSelectedItems();
269
-
270
- this.sortedListItems.sort((a, b) => {
271
- const hasItemA = selectedItems.includes(a);
272
- const hasItemB = selectedItems.includes(b);
273
-
274
- if (hasItemA === hasItemB) {
275
- return a[this.dataValueExpr] - b[this.dataValueExpr];
276
- } else if (hasItemA < hasItemB) {
277
- return 1;
278
- } else {
279
- return -1;
280
- }
281
- });
282
- },
283
- },
284
- };
285
- </script>
286
-
287
- <style lang="scss">
288
- @import 'settings-tools/all-settings';
289
- @import 'components/c.checkbox';
290
- @import 'components/_c.dropdown';
291
-
292
- .mc-dropdown {
293
- max-width: var(--max-width);
294
-
295
- &__tag {
296
- position: absolute;
297
- top: 0;
298
- transform: translateY(50%);
299
- }
300
-
301
- &__trigger {
302
- display: block;
303
- text-align: left;
304
-
305
- &.is-open {
306
- background-image: url(inline-icons('arrow-top-16', black));
307
- }
308
- }
309
- }
310
-
311
- .mc-dropdown--multi .mc-dropdown__trigger {
312
- overflow: hidden;
313
- padding-left: calc(0.75rem + var(--tag-width));
314
- text-overflow: ellipsis;
315
- white-space: nowrap;
316
- }
317
- </style>
@@ -1,7 +0,0 @@
1
- import MDropdown from './MDropdown.vue';
2
-
3
- MDropdown.install = function (Vue) {
4
- Vue.component(MDropdown.name, MDropdown);
5
- };
6
-
7
- export { MDropdown };
@@ -1,7 +0,0 @@
1
- import MField from './MField.vue';
2
-
3
- MField.install = function (Vue) {
4
- Vue.component(MField.name, MField);
5
- };
6
-
7
- export { MField };
@@ -1,149 +0,0 @@
1
- <template>
2
- <ul class="mc-fileuploader__files">
3
- <li
4
- v-for="(file, index) in files"
5
- :key="`file-${index}`"
6
- class="mc-fileuploader__file"
7
- :class="
8
- checkFileStatus(file)
9
- ? 'mc-fileuploader__file--is-valid'
10
- : 'mc-fileuploader__file--is-invalid'
11
- "
12
- >
13
- <span class="mc-fileuploader__file-name">{{ file.name }}</span>
14
- <span class="mc-fileuploader__file-icon">&nbsp;</span>
15
- <button
16
- type="button"
17
- class="mc-fileuploader__delete"
18
- :aria-label="removeLabel"
19
- :disabled="disabled"
20
- @click="deleteFile(file)"
21
- ></button>
22
- <div
23
- v-if="`${$slots}.errorMessage${index}` && !checkFileStatus(file)"
24
- class="mc-fileuploader__file-message"
25
- >
26
- <slot :name="`errorMessage${index}`" />
27
- </div>
28
- </li>
29
- </ul>
30
- </template>
31
-
32
- <script>
33
- export default {
34
- name: 'MFileResult',
35
- inheritAttrs: false,
36
- props: {
37
- files: {
38
- type: [Array, FileList],
39
- default: function () {
40
- return [];
41
- },
42
- },
43
- allowedExtensions: {
44
- type: Array,
45
- default: function () {
46
- return [];
47
- },
48
- },
49
- maxSize: {
50
- type: Number,
51
- default: null,
52
- },
53
- removeLabel: {
54
- type: String,
55
- default: '',
56
- },
57
- disabled: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- },
62
- watch: {
63
- files: {
64
- handler: function () {
65
- const files = Object.values(this.files);
66
- const invalidFiles = [];
67
-
68
- files.forEach((file, index) => {
69
- const fileName = file.name;
70
- const fileSize = file.size;
71
- const validExtension = this.checkFileExtension(fileName);
72
- const validSize = this.checkFileSize(fileSize);
73
- let errorType = '';
74
-
75
- if (!validExtension) {
76
- errorType = 'invalid-extension';
77
- }
78
-
79
- if (!validSize) {
80
- errorType = 'invalid-size';
81
- }
82
-
83
- if (!validExtension || !validSize) {
84
- invalidFiles.push({
85
- index: index,
86
- fileName: fileName,
87
- fileSize: fileSize,
88
- errorType: errorType,
89
- });
90
- }
91
- });
92
-
93
- if (invalidFiles.length > 0) {
94
- this.$emit('has-invalid-files', invalidFiles);
95
- }
96
- },
97
- immediate: true,
98
- },
99
- },
100
- methods: {
101
- deleteFile(file) {
102
- this.$emit('file-removed', file);
103
- },
104
- checkFileExtension(fileName) {
105
- const allowedExtensions = this.allowedExtensions;
106
-
107
- if (allowedExtensions.length > 0) {
108
- const extension = fileName.slice(
109
- ((fileName.lastIndexOf('.') - 1) >>> 0) + 2
110
- );
111
-
112
- if (!allowedExtensions.includes(extension)) {
113
- return false; // invalid
114
- }
115
- }
116
-
117
- return true; // valid
118
- },
119
- checkFileSize(fileSize) {
120
- const fileSizeMB = fileSize / 1024 / 1024; // in MB
121
-
122
- if (this.maxSize && fileSizeMB > this.maxSize) {
123
- return false; // invalid
124
- }
125
-
126
- return true; // valid
127
- },
128
- checkFileStatus(file) {
129
- const validExtension = this.checkFileExtension(file.name);
130
- const validSize = this.checkFileSize(file.size);
131
-
132
- if (!validExtension || !validSize) {
133
- return false; // invalid
134
- }
135
-
136
- return true; // valid
137
- },
138
- },
139
- };
140
- </script>
141
-
142
- <style lang="scss">
143
- @import 'settings-tools/_all-settings';
144
- @import 'components/_c.file-uploader';
145
-
146
- .mc-fileuploader__file {
147
- box-sizing: content-box;
148
- }
149
- </style>