@mozaic-ds/vue 1.0.0-beta.5 → 1.0.0-beta.8
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/README.md +19 -160
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +324 -141
- package/dist/mozaic-vue.js +870 -542
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +1 -1
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/components/GettingStarted.mdx +1 -1
- package/src/components/Introduction.mdx +35 -9
- package/src/components/Support.mdx +1 -1
- package/src/components/breadcrumb/MBreadcrumb.stories.ts +27 -0
- package/src/components/divider/MDivider.spec.ts +57 -0
- package/src/components/divider/MDivider.stories.ts +64 -0
- package/src/components/divider/MDivider.vue +56 -0
- package/src/components/link/MLink.vue +1 -1
- package/src/components/numberbadge/MNumberBadge.spec.ts +56 -0
- package/src/components/{badge/MBadge.stories.ts → numberbadge/MNumberBadge.stories.ts} +8 -8
- package/src/components/{badge/MBadge.vue → numberbadge/MNumberBadge.vue} +4 -4
- package/src/components/pagination/MPagination.spec.ts +123 -0
- package/src/components/pagination/MPagination.stories.ts +83 -0
- package/src/components/pagination/MPagination.vue +140 -0
- package/src/components/tabs/MTabs.stories.ts +104 -0
- package/src/components/tabs/MTabs.vue +113 -0
- package/src/components/tabs/Mtabs.spec.ts +154 -0
- package/src/components/tag/MTag.spec.ts +107 -0
- package/src/components/tag/MTag.stories.ts +75 -0
- package/src/components/tag/MTag.vue +154 -0
- package/src/main.ts +26 -47
- package/src/components/badge/MBadge.spec.ts +0 -16
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
v-if="type === 'selectable'"
|
|
4
|
+
:for="id"
|
|
5
|
+
class="mc-tag"
|
|
6
|
+
:class="classObject"
|
|
7
|
+
>
|
|
8
|
+
<input
|
|
9
|
+
type="checkbox"
|
|
10
|
+
class="mc-tag__input"
|
|
11
|
+
:id="id"
|
|
12
|
+
:name="name"
|
|
13
|
+
:checked="modelValue"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
@change="
|
|
16
|
+
emit('update:modelValue', ($event.target as HTMLInputElement).checked)
|
|
17
|
+
"
|
|
18
|
+
v-bind="$attrs"
|
|
19
|
+
/>
|
|
20
|
+
<span class="mc-tag__label">{{ label }}</span>
|
|
21
|
+
</label>
|
|
22
|
+
|
|
23
|
+
<button
|
|
24
|
+
v-else-if="type === 'interactive'"
|
|
25
|
+
class="mc-tag"
|
|
26
|
+
type="button"
|
|
27
|
+
:class="classObject"
|
|
28
|
+
:disabled="disabled"
|
|
29
|
+
v-bind="$attrs"
|
|
30
|
+
>
|
|
31
|
+
<span class="mc-tag__label">{{ label }}</span>
|
|
32
|
+
</button>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
v-else-if="type === 'contextualised'"
|
|
36
|
+
class="mc-tag"
|
|
37
|
+
type="button"
|
|
38
|
+
:class="classObject"
|
|
39
|
+
:disabled="disabled"
|
|
40
|
+
v-bind="$attrs"
|
|
41
|
+
>
|
|
42
|
+
<MNumberBadge
|
|
43
|
+
appearance="inverse"
|
|
44
|
+
:label="contextualisedNumber"
|
|
45
|
+
:size="size === 'l' ? 'm' : undefined"
|
|
46
|
+
/>
|
|
47
|
+
<span class="mc-tag__label">{{ label }}</span>
|
|
48
|
+
</button>
|
|
49
|
+
|
|
50
|
+
<span
|
|
51
|
+
v-else-if="type === 'removable'"
|
|
52
|
+
class="mc-tag"
|
|
53
|
+
:class="classObject"
|
|
54
|
+
v-bind="$attrs"
|
|
55
|
+
>
|
|
56
|
+
<span class="mc-tag__label">{{ label }}</span>
|
|
57
|
+
<button
|
|
58
|
+
class="mc-tag-removable__remove"
|
|
59
|
+
type="button"
|
|
60
|
+
@click="id && emit('remove-tag', id)"
|
|
61
|
+
>
|
|
62
|
+
<CrossCircleFilled24
|
|
63
|
+
class="mc-tag-removable__icon"
|
|
64
|
+
aria-hidden="true"
|
|
65
|
+
/>
|
|
66
|
+
<span class="mc-tag-removable__text">removableLabel</span>
|
|
67
|
+
</button>
|
|
68
|
+
</span>
|
|
69
|
+
|
|
70
|
+
<!-- informative -->
|
|
71
|
+
<span v-else class="mc-tag" :class="classObject" v-bind="$attrs">
|
|
72
|
+
<span class="mc-tag__label">{{ label }}</span>
|
|
73
|
+
</span>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import { computed } from 'vue';
|
|
78
|
+
import CrossCircleFilled24 from '@mozaic-ds/icons-vue/src/components/CrossCircleFilled24/CrossCircleFilled24.vue';
|
|
79
|
+
import MNumberBadge from '../numberbadge/MNumberBadge.vue';
|
|
80
|
+
/**
|
|
81
|
+
* A Tag is a UI element used to filter data, categorize, select or deselect an option. It can appear standalone, in a group, or embedded within other components. Depending on its use, a tag can be interactive (clickable, removable, selectable) or static (serving as a visual indicator).
|
|
82
|
+
*/
|
|
83
|
+
const props = withDefaults(
|
|
84
|
+
defineProps<{
|
|
85
|
+
/**
|
|
86
|
+
* Defines the behavior and layout of the tag.
|
|
87
|
+
*/
|
|
88
|
+
type?:
|
|
89
|
+
| 'informative'
|
|
90
|
+
| 'interactive'
|
|
91
|
+
| 'contextualised'
|
|
92
|
+
| 'removable'
|
|
93
|
+
| 'selectable';
|
|
94
|
+
/**
|
|
95
|
+
* Determines the size of the tag.
|
|
96
|
+
*/
|
|
97
|
+
size?: 's' | 'm' | 'l';
|
|
98
|
+
/**
|
|
99
|
+
* A unique identifier for the tag, used to associate the label with the form element. **Required** when type is 'selectable' or 'removable'.
|
|
100
|
+
*/
|
|
101
|
+
id?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The name attribute for the tag element, typically used for form submission. (only relevant for type: 'selectable').
|
|
104
|
+
*/
|
|
105
|
+
name?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The text label displayed next to the tag.
|
|
108
|
+
*/
|
|
109
|
+
label: string;
|
|
110
|
+
/**
|
|
111
|
+
* The tag's checked state, bound via v-model. Used only for type: 'selectable'.
|
|
112
|
+
*/
|
|
113
|
+
modelValue?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* If `true`, disables the tag, making it non-interactive. Applicable to selectable, interactive, and contextualised types.
|
|
116
|
+
*/
|
|
117
|
+
disabled?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* A number displayed in the badge when the tag is contextualised.
|
|
120
|
+
*/
|
|
121
|
+
contextualisedNumber?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Accessible label text for the remove button in removable tags.
|
|
124
|
+
*/
|
|
125
|
+
removableLabel?: string;
|
|
126
|
+
}>(),
|
|
127
|
+
{
|
|
128
|
+
type: 'informative',
|
|
129
|
+
contextualisedNumber: 99,
|
|
130
|
+
},
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const classObject = computed(() => {
|
|
134
|
+
return {
|
|
135
|
+
[`mc-tag-${props.type}`]: props.type && props.type != 'informative',
|
|
136
|
+
[`mc-tag--${props.size}`]: props.size && props.size != 'm',
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const emit = defineEmits<{
|
|
141
|
+
/**
|
|
142
|
+
* Emits when the tag value changes, updating the modelValue prop.
|
|
143
|
+
*/
|
|
144
|
+
(on: 'update:modelValue', value: boolean): void;
|
|
145
|
+
/**
|
|
146
|
+
* Emits when the remove button of a tag is clicked, passing the tag's ID.
|
|
147
|
+
*/
|
|
148
|
+
(on: 'remove-tag', id: string): void;
|
|
149
|
+
}>();
|
|
150
|
+
</script>
|
|
151
|
+
|
|
152
|
+
<style lang="scss" scoped>
|
|
153
|
+
@use '@mozaic-ds/styles/components/tag';
|
|
154
|
+
</style>
|
package/src/main.ts
CHANGED
|
@@ -1,47 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
MButton,
|
|
28
|
-
MCheckbox,
|
|
29
|
-
MCheckboxGroup,
|
|
30
|
-
MField,
|
|
31
|
-
MFieldGroup,
|
|
32
|
-
MIconButton,
|
|
33
|
-
MLink,
|
|
34
|
-
MLoader,
|
|
35
|
-
MOverlay,
|
|
36
|
-
MPasswordInput,
|
|
37
|
-
MQuantitySelector,
|
|
38
|
-
MRadio,
|
|
39
|
-
MRadioGroup,
|
|
40
|
-
MSelect,
|
|
41
|
-
MStatusBadge,
|
|
42
|
-
MStatusNotification,
|
|
43
|
-
MTextArea,
|
|
44
|
-
MTextInput,
|
|
45
|
-
MToggle,
|
|
46
|
-
MToggleGroup,
|
|
47
|
-
};
|
|
1
|
+
export { default as MBreadcrumb } from './components/breadcrumb/MBreadcrumb.vue';
|
|
2
|
+
export { default as MButton } from './components/button/MButton.vue';
|
|
3
|
+
export { default as MCheckbox } from './components/checkbox/MCheckbox.vue';
|
|
4
|
+
export { default as MCheckboxGroup } from './components/checkboxgroup/MCheckboxGroup.vue';
|
|
5
|
+
export { default as MDivider } from './components/divider/MDivider.vue';
|
|
6
|
+
export { default as MField } from './components/field/MField.vue';
|
|
7
|
+
export { default as MFieldGroup } from './components/fieldgroup/MFieldGroup.vue';
|
|
8
|
+
export { default as MIconButton } from './components/iconbutton/MIconButton.vue';
|
|
9
|
+
export { default as MLink } from './components/link/MLink.vue';
|
|
10
|
+
export { default as MLoader } from './components/loader/MLoader.vue';
|
|
11
|
+
export { default as MNumberBadge } from './components/numberbadge/MNumberBadge.vue';
|
|
12
|
+
export { default as MOverlay } from './components/overlay/MOverlay.vue';
|
|
13
|
+
export { default as MPagination } from './components/pagination/MPagination.vue';
|
|
14
|
+
export { default as MPasswordInput } from './components/passwordinput/MPasswordInput.vue';
|
|
15
|
+
export { default as MQuantitySelector } from './components/quantityselector/MQuantitySelector.vue';
|
|
16
|
+
export { default as MRadio } from './components/radio/MRadio.vue';
|
|
17
|
+
export { default as MRadioGroup } from './components/radiogroup/MRadioGroup.vue';
|
|
18
|
+
export { default as MSelect } from './components/select/MSelect.vue';
|
|
19
|
+
export { default as MStatusBadge } from './components/statusbadge/MStatusBadge.vue';
|
|
20
|
+
export { default as MStatusNotification } from './components/statusnotification/MStatusNotification.vue';
|
|
21
|
+
export { default as MTabs } from './components/tabs/MTabs.vue';
|
|
22
|
+
export { default as MTag } from './components/tag/MTag.vue';
|
|
23
|
+
export { default as MTextArea } from './components/textarea/MTextArea.vue';
|
|
24
|
+
export { default as MTextInput } from './components/textinput/MTextInput.vue';
|
|
25
|
+
export { default as MToggle } from './components/toggle/MToggle.vue';
|
|
26
|
+
export { default as MToggleGroup } from './components/togglegroup/MToggleGroup.vue';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { mount } from '@vue/test-utils';
|
|
4
|
-
import MBadge from './MBadge.vue';
|
|
5
|
-
|
|
6
|
-
describe('MBadge component', () => {
|
|
7
|
-
it('renders properly', () => {
|
|
8
|
-
const wrapper = mount(MBadge, {
|
|
9
|
-
props: {
|
|
10
|
-
label: 99,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(wrapper.text()).toContain('99');
|
|
15
|
-
});
|
|
16
|
-
});
|