@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.
- package/LICENSE +51 -0
- package/README.md +224 -82
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +1202 -0
- package/dist/mozaic-vue.js +1220 -0
- package/dist/mozaic-vue.js.map +1 -0
- package/dist/mozaic-vue.umd.cjs +2 -0
- package/dist/mozaic-vue.umd.cjs.map +1 -0
- package/env.d.ts +1 -0
- package/package.json +81 -50
- package/src/components/Contributing.mdx +118 -0
- package/src/components/GettingStarted.mdx +50 -0
- package/src/components/Introduction.mdx +54 -0
- package/src/components/Support.mdx +18 -0
- package/src/components/badge/MBadge.spec.ts +16 -0
- package/src/components/badge/MBadge.stories.ts +50 -0
- package/src/components/badge/MBadge.vue +36 -34
- package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
- package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -0
- package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
- package/src/components/button/MButton.spec.ts +191 -0
- package/src/components/button/MButton.stories.ts +66 -0
- package/src/components/button/MButton.vue +98 -154
- package/src/components/checkbox/MCheckbox.spec.ts +104 -0
- package/src/components/checkbox/MCheckbox.stories.ts +83 -0
- package/src/components/checkbox/MCheckbox.vue +60 -101
- package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
- package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
- package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
- package/src/components/field/MField.spec.ts +166 -0
- package/src/components/field/MField.stories.ts +376 -0
- package/src/components/field/MField.vue +78 -61
- package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
- package/src/components/fieldgroup/MFieldGroup.stories.ts +423 -0
- package/src/components/fieldgroup/MFieldGroup.vue +79 -0
- package/src/components/iconbutton/MIconButton.spec.ts +108 -0
- package/src/components/iconbutton/MIconButton.stories.ts +66 -0
- package/src/components/iconbutton/MIconButton.vue +73 -0
- package/src/components/link/MLink.spec.ts +154 -0
- package/src/components/link/MLink.stories.ts +98 -0
- package/src/components/link/MLink.vue +86 -109
- package/src/components/loader/MLoader.spec.ts +104 -0
- package/src/components/loader/MLoader.stories.ts +45 -0
- package/src/components/loader/MLoader.vue +65 -55
- package/src/components/overlay/MOverlay.spec.ts +51 -0
- package/src/components/overlay/MOverlay.stories.ts +40 -0
- package/src/components/overlay/MOverlay.vue +27 -19
- package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
- package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
- package/src/components/passwordinput/MPasswordInput.vue +129 -76
- package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
- package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
- package/src/components/quantityselector/MQuantitySelector.vue +160 -136
- package/src/components/radio/MRadio.spec.ts +104 -0
- package/src/components/radio/MRadio.stories.ts +68 -0
- package/src/components/radio/MRadio.vue +56 -39
- package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
- package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
- package/src/components/radiogroup/MRadioGroup.vue +79 -0
- package/src/components/select/MSelect.spec.ts +114 -0
- package/src/components/select/MSelect.stories.ts +101 -0
- package/src/components/select/MSelect.vue +77 -119
- package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
- package/src/components/statusbadge/MStatusBadge.vue +40 -0
- package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
- package/src/components/statusdot/MStatusDot.spec.ts +51 -0
- package/src/components/statusdot/MStatusDot.stories.ts +48 -0
- package/src/components/statusdot/MStatusDot.vue +36 -0
- package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
- package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
- package/src/components/statusnotification/MStatusNotification.vue +106 -0
- package/src/components/textarea/MTextArea.spec.ts +112 -0
- package/src/components/textarea/MTextArea.stories.ts +67 -0
- package/src/components/textarea/MTextArea.vue +81 -42
- package/src/components/textinput/MTextInput.spec.ts +121 -0
- package/src/components/textinput/MTextInput.stories.ts +114 -0
- package/src/components/textinput/MTextInput.vue +127 -47
- package/src/components/toggle/MToggle.spec.ts +99 -0
- package/src/components/toggle/MToggle.stories.ts +68 -0
- package/src/components/toggle/MToggle.vue +63 -103
- package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
- package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
- package/src/components/togglegroup/MToggleGroup.vue +97 -0
- package/src/components/usingIcons.mdx +43 -0
- package/src/components/usingPresets.mdx +125 -0
- package/src/main.ts +47 -0
- package/dist/demo.html +0 -1
- package/dist/mozaic-vue.adeo.css +0 -45
- package/dist/mozaic-vue.adeo.umd.js +0 -41775
- package/dist/mozaic-vue.common.js +0 -41765
- package/dist/mozaic-vue.common.js.map +0 -1
- package/dist/mozaic-vue.umd.js +0 -41776
- package/dist/mozaic-vue.umd.js.map +0 -1
- package/dist/mozaic-vue.umd.min.js +0 -4
- package/dist/mozaic-vue.umd.min.js.map +0 -1
- package/postinstall.js +0 -3
- package/src/components/accordion/MAccordion.vue +0 -128
- package/src/components/accordion/index.js +0 -7
- package/src/components/autocomplete/MAutocomplete.vue +0 -198
- package/src/components/autocomplete/index.js +0 -7
- package/src/components/badge/index.js +0 -7
- package/src/components/breadcrumb/index.js +0 -7
- package/src/components/button/index.js +0 -7
- package/src/components/card/MCard.vue +0 -78
- package/src/components/card/index.js +0 -7
- package/src/components/checkbox/MCheckboxGroup.vue +0 -155
- package/src/components/checkbox/index.js +0 -12
- package/src/components/container/MContainer.vue +0 -33
- package/src/components/container/index.js +0 -7
- package/src/components/datatable/MDataTable.vue +0 -651
- package/src/components/datatable/MDataTableHeader.vue +0 -55
- package/src/components/datatable/MDataTableTop.vue +0 -35
- package/src/components/datatable/helpers.js +0 -132
- package/src/components/datatable/index.js +0 -12
- package/src/components/field/index.js +0 -7
- package/src/components/fileuploader/MFileResult.vue +0 -149
- package/src/components/fileuploader/MFileUploader.vue +0 -142
- package/src/components/fileuploader/index.js +0 -7
- package/src/components/flag/MFlag.vue +0 -46
- package/src/components/flag/index.js +0 -7
- package/src/components/heading/MHeading.vue +0 -75
- package/src/components/heading/index.js +0 -7
- package/src/components/hero/MHero.vue +0 -93
- package/src/components/hero/index.js +0 -7
- package/src/components/icon/MIcon.vue +0 -120
- package/src/components/icon/index.js +0 -7
- package/src/components/index.js +0 -43
- package/src/components/layer/MLayer.vue +0 -208
- package/src/components/layer/index.js +0 -7
- package/src/components/link/index.js +0 -7
- package/src/components/listbox/MListBox.vue +0 -106
- package/src/components/listbox/index.js +0 -7
- package/src/components/loader/index.js +0 -7
- package/src/components/modal/MModal.vue +0 -179
- package/src/components/modal/index.js +0 -7
- package/src/components/notification/MNotification.vue +0 -110
- package/src/components/notification/index.js +0 -7
- package/src/components/optionbutton/MOptionButton.vue +0 -67
- package/src/components/optionbutton/index.js +0 -7
- package/src/components/optioncard/MOptionCard.vue +0 -132
- package/src/components/optioncard/index.js +0 -7
- package/src/components/optiongroup/MOptionGroup.vue +0 -18
- package/src/components/optiongroup/index.js +0 -7
- package/src/components/overlay/MOverlayLoader.vue +0 -43
- package/src/components/overlay/index.js +0 -12
- package/src/components/pagination/MPagination.vue +0 -162
- package/src/components/pagination/index.js +0 -7
- package/src/components/passwordinput/index.js +0 -7
- package/src/components/phonenumber/MPhoneNumber.vue +0 -390
- package/src/components/phonenumber/index.js +0 -7
- package/src/components/progressbar/MProgress.vue +0 -102
- package/src/components/progressbar/index.js +0 -7
- package/src/components/quantityselector/index.js +0 -7
- package/src/components/radio/MRadioGroup.vue +0 -111
- package/src/components/radio/index.js +0 -12
- package/src/components/ratingstars/MStarsInput.vue +0 -118
- package/src/components/ratingstars/MStarsResult.vue +0 -89
- package/src/components/ratingstars/index.js +0 -12
- package/src/components/select/index.js +0 -7
- package/src/components/stepper/MStepper.vue +0 -70
- package/src/components/stepper/index.js +0 -7
- package/src/components/tabs/MTab.vue +0 -184
- package/src/components/tabs/index.js +0 -7
- package/src/components/tags/MTag.vue +0 -173
- package/src/components/tags/index.js +0 -7
- package/src/components/textarea/index.js +0 -7
- package/src/components/textinput/MTextInputField.vue +0 -105
- package/src/components/textinput/MTextInputIcon.vue +0 -42
- package/src/components/textinput/index.js +0 -7
- package/src/components/toggle/index.js +0 -7
- package/src/components/tooltip/MTooltip.vue +0 -42
- package/src/components/tooltip/index.js +0 -7
- package/src/index.js +0 -62
- package/src/shims-tsx.d.ts +0 -13
- package/src/shims.vue.d.ts +0 -4
- package/src/tokens/adeo/android/colors.xml +0 -391
- package/src/tokens/adeo/android/font_dimens.xml +0 -18
- package/src/tokens/adeo/css/_variables.scss +0 -385
- package/src/tokens/adeo/css/root.scss +0 -387
- package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -399
- package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -411
- package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -394
- package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
- package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
- package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
- package/src/tokens/adeo/js/tokens.js +0 -483
- package/src/tokens/adeo/js/tokensObject.js +0 -10354
- package/src/tokens/adeo/scss/_tokens.scss +0 -1300
- package/src/utils/mozaicClasses.js +0 -16
- package/src/utils/theme.validator.js +0 -19
- package/types/index.d.ts +0 -100
|
@@ -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,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"> </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>
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="mc-fileuploader" :class="cssFieldElementClass">
|
|
3
|
-
<input
|
|
4
|
-
:id="id"
|
|
5
|
-
ref="fileUpload"
|
|
6
|
-
type="file"
|
|
7
|
-
class="mc-fileuploader__input"
|
|
8
|
-
:accept="accept"
|
|
9
|
-
:multiple="multiple"
|
|
10
|
-
:disabled="disabled"
|
|
11
|
-
@change="onChange"
|
|
12
|
-
/>
|
|
13
|
-
<label :for="id" class="mc-fileuploader__label">
|
|
14
|
-
<span class="mc-fileuploader__label--center">
|
|
15
|
-
{{ label }}
|
|
16
|
-
</span>
|
|
17
|
-
</label>
|
|
18
|
-
<m-file-result
|
|
19
|
-
v-if="displayFilesList && files.length > 0"
|
|
20
|
-
:files="files"
|
|
21
|
-
:allowed-extensions="allowedExtensions"
|
|
22
|
-
:max-size="maxSize"
|
|
23
|
-
:remove-label="removeLabel"
|
|
24
|
-
@file-removed="deleteFile"
|
|
25
|
-
@has-invalid-files="hasInvalidFiles"
|
|
26
|
-
>
|
|
27
|
-
<template v-for="(index, name) in $slots" #[name]>
|
|
28
|
-
<slot :name="name" />
|
|
29
|
-
</template>
|
|
30
|
-
</m-file-result>
|
|
31
|
-
<m-file-result
|
|
32
|
-
v-if="uploadedFiles.length > 0"
|
|
33
|
-
:files="uploadedFiles"
|
|
34
|
-
:allowed-extensions="allowedExtensions"
|
|
35
|
-
:remove-label="removeLabel"
|
|
36
|
-
:disabled="disabled"
|
|
37
|
-
@file-removed="deleteRemoteFile"
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<script>
|
|
43
|
-
import MFileResult from './MFileResult.vue';
|
|
44
|
-
export default {
|
|
45
|
-
name: 'MFileUploader',
|
|
46
|
-
components: {
|
|
47
|
-
MFileResult,
|
|
48
|
-
},
|
|
49
|
-
inject: {
|
|
50
|
-
cssFieldElementClass: {
|
|
51
|
-
default: '',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
inheritAttrs: false,
|
|
55
|
-
props: {
|
|
56
|
-
id: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: 'mc-fileuploader',
|
|
59
|
-
},
|
|
60
|
-
label: {
|
|
61
|
-
type: String,
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
accept: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: null,
|
|
67
|
-
},
|
|
68
|
-
multiple: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: false,
|
|
71
|
-
},
|
|
72
|
-
allowedExtensions: {
|
|
73
|
-
type: Array,
|
|
74
|
-
default: function () {
|
|
75
|
-
return [];
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
maxSize: {
|
|
79
|
-
type: Number,
|
|
80
|
-
default: null,
|
|
81
|
-
},
|
|
82
|
-
displayFilesList: {
|
|
83
|
-
type: Boolean,
|
|
84
|
-
default: true,
|
|
85
|
-
},
|
|
86
|
-
uploadedFiles: {
|
|
87
|
-
type: [Array, Object],
|
|
88
|
-
default: function () {
|
|
89
|
-
return [];
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
disabled: {
|
|
93
|
-
type: Boolean,
|
|
94
|
-
default: false,
|
|
95
|
-
},
|
|
96
|
-
removeLabel: {
|
|
97
|
-
type: String,
|
|
98
|
-
default: 'Remove',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
data() {
|
|
102
|
-
return {
|
|
103
|
-
files: [],
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
methods: {
|
|
107
|
-
onChange(e) {
|
|
108
|
-
this.files = [...e.target.files];
|
|
109
|
-
this.$emit('file-added', this.files);
|
|
110
|
-
e.target.value = '';
|
|
111
|
-
},
|
|
112
|
-
removeFromArray(fileList, value) {
|
|
113
|
-
const array = Array.from(fileList);
|
|
114
|
-
const idx = array.indexOf(value);
|
|
115
|
-
if (idx !== -1) {
|
|
116
|
-
array.splice(idx, 1);
|
|
117
|
-
}
|
|
118
|
-
return array;
|
|
119
|
-
},
|
|
120
|
-
deleteFile(file) {
|
|
121
|
-
this.files = this.removeFromArray(this.files, file);
|
|
122
|
-
this.$emit('file-removed', file);
|
|
123
|
-
},
|
|
124
|
-
deleteRemoteFile(file) {
|
|
125
|
-
this.$emit('remote-file-removed', file);
|
|
126
|
-
},
|
|
127
|
-
hasInvalidFiles(payload) {
|
|
128
|
-
this.$emit('has-invalid-files', payload);
|
|
129
|
-
},
|
|
130
|
-
reset() {
|
|
131
|
-
this.$emit('file-removed', [...this.files]);
|
|
132
|
-
this.files = [];
|
|
133
|
-
this.$refs.fileUpload.value = '';
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
</script>
|
|
138
|
-
|
|
139
|
-
<style lang="scss">
|
|
140
|
-
@import 'settings-tools/_all-settings';
|
|
141
|
-
@import 'components/_c.file-uploader';
|
|
142
|
-
</style>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="htmlTag" class="mc-flag" :class="setClasses">
|
|
3
|
-
{{ label }}
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import { checkThemeValue } from '../../utils/theme.validator';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: 'MFlag',
|
|
12
|
-
|
|
13
|
-
props: {
|
|
14
|
-
label: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
theme: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: null,
|
|
21
|
-
validator: (value) => checkThemeValue(value),
|
|
22
|
-
},
|
|
23
|
-
htmlTag: {
|
|
24
|
-
type: String,
|
|
25
|
-
default: 'div',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
computed: {
|
|
30
|
-
setClasses() {
|
|
31
|
-
const classes = [];
|
|
32
|
-
|
|
33
|
-
if (this.theme) {
|
|
34
|
-
classes.push(`mc-flag--${this.theme}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return classes;
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<style lang="scss">
|
|
44
|
-
@import 'settings-tools/_all-settings';
|
|
45
|
-
@import 'components/_c.flag';
|
|
46
|
-
</style>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="hn" class="mt-heading" :class="classes">
|
|
3
|
-
<slot />
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: 'MHeading',
|
|
10
|
-
|
|
11
|
-
props: {
|
|
12
|
-
level: {
|
|
13
|
-
type: String,
|
|
14
|
-
default: '1',
|
|
15
|
-
validator: (value) => ['1', '2', '3', '4'].includes(value),
|
|
16
|
-
},
|
|
17
|
-
size: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: 'm',
|
|
20
|
-
validator: (value) => ['s', 'm', 'l'].includes(value),
|
|
21
|
-
},
|
|
22
|
-
weight: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: null,
|
|
25
|
-
validator: (value) => ['light', 'semi-bold'].includes(value),
|
|
26
|
-
},
|
|
27
|
-
underline: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
31
|
-
underlineColor: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: null,
|
|
34
|
-
validator: (value) =>
|
|
35
|
-
['primary-01-200', 'primary-02-600', 'primary-02-200'].includes(value),
|
|
36
|
-
},
|
|
37
|
-
lightest: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false,
|
|
40
|
-
},
|
|
41
|
-
align: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: 'left',
|
|
44
|
-
validator: (value) => ['left', 'center', 'right'].includes(value),
|
|
45
|
-
},
|
|
46
|
-
lineHeightXS: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
computed: {
|
|
53
|
-
hn() {
|
|
54
|
-
return `h${this.level}`;
|
|
55
|
-
},
|
|
56
|
-
classes() {
|
|
57
|
-
return {
|
|
58
|
-
['mt-heading--' + this.size]: this.size,
|
|
59
|
-
['mt-heading--' + this.weight]:
|
|
60
|
-
this.weight === 'light' || this.weight === 'semi-bold',
|
|
61
|
-
'mt-heading--lightest': this.lightest,
|
|
62
|
-
'mt-heading--underline': this.underline,
|
|
63
|
-
['mt-heading--line-' + this.underlineColor]: this.underlineColor,
|
|
64
|
-
['mt-heading--' + this.align]: this.align,
|
|
65
|
-
'mt-heading--line-height-xs': this.lineHeightXS,
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
</script>
|
|
71
|
-
|
|
72
|
-
<style lang="scss">
|
|
73
|
-
@import 'settings-tools/_all-settings';
|
|
74
|
-
@import 'typography/_t.headings';
|
|
75
|
-
</style>
|