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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +14 -6
  2. package/dist/mozaic-vue.css +1 -1
  3. package/dist/mozaic-vue.d.ts +349 -67
  4. package/dist/mozaic-vue.js +670 -327
  5. package/dist/mozaic-vue.js.map +1 -1
  6. package/dist/mozaic-vue.umd.cjs +1 -1
  7. package/dist/mozaic-vue.umd.cjs.map +1 -1
  8. package/package.json +3 -2
  9. package/src/components/GettingStarted.mdx +15 -4
  10. package/src/components/badge/MBadge.stories.ts +1 -1
  11. package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
  12. package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -0
  13. package/src/components/breadcrumb/MBreadcrumb.vue +70 -0
  14. package/src/components/button/MButton.stories.ts +1 -1
  15. package/src/components/checkbox/MCheckbox.stories.ts +1 -1
  16. package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +1 -1
  17. package/src/components/checkboxgroup/MCheckboxGroup.vue +2 -2
  18. package/src/components/field/MField.stories.ts +1 -1
  19. package/src/components/fieldgroup/MFieldGroup.stories.ts +175 -26
  20. package/src/components/iconbutton/MIconButton.stories.ts +1 -1
  21. package/src/components/loader/MLoader.stories.ts +1 -1
  22. package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
  23. package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
  24. package/src/components/passwordinput/MPasswordInput.vue +149 -0
  25. package/src/components/quantityselector/MQuantitySelector.stories.ts +1 -1
  26. package/src/components/radio/MRadio.stories.ts +1 -1
  27. package/src/components/radiogroup/MRadioGroup.stories.ts +1 -1
  28. package/src/components/select/MSelect.stories.ts +1 -1
  29. package/src/components/statusbadge/MStatusBadge.stories.ts +5 -5
  30. package/src/components/statusbadge/MStatusBadge.vue +6 -6
  31. package/src/components/statusdot/MStatusDot.spec.ts +51 -0
  32. package/src/components/statusdot/MStatusDot.stories.ts +48 -0
  33. package/src/components/{statusbadge → statusdot}/MStatusDot.vue +8 -4
  34. package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
  35. package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
  36. package/src/components/statusnotification/MStatusNotification.vue +106 -0
  37. package/src/components/textarea/MTextArea.stories.ts +1 -1
  38. package/src/components/textinput/MTextInput.stories.ts +1 -1
  39. package/src/components/toggle/MToggle.stories.ts +2 -2
  40. package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
  41. package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
  42. package/src/components/togglegroup/MToggleGroup.vue +97 -0
  43. package/src/main.ts +8 -0
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <div class="mc-password-input mc-text-input" :class="classObject">
3
+ <input
4
+ class="mc-password-input__control mc-text-input__control"
5
+ v-model="modelValue"
6
+ :id="id"
7
+ :type="inputType"
8
+ :name="name"
9
+ :placeholder="placeholder"
10
+ :disabled="disabled"
11
+ :aria-invalid="isInvalid"
12
+ :readonly="readonly"
13
+ v-bind="$attrs"
14
+ @input="
15
+ emit('update:modelValue', ($event.target as HTMLInputElement).value)
16
+ "
17
+ />
18
+ <div v-if="isClearable && modelValue" class="mc-controls-options">
19
+ <button
20
+ class="mc-controls-options__button"
21
+ @click="clearValue"
22
+ >
23
+ <CrossCircleFilled24
24
+ class="mc-controls-options__icon"
25
+ aria-hidden="true"
26
+ />
27
+ <span class="mc-controls-options__label">{{ clearLabel }}</span>
28
+ </button>
29
+ </div>
30
+ <MButton
31
+ ref="button"
32
+ role="switch"
33
+ :aria-checked="ariaChecked"
34
+ :disabled="disabled"
35
+ @click="toggleVisibility"
36
+ size="s"
37
+ ghost
38
+ >
39
+ {{ isVisible ? buttonLabel.hide : buttonLabel.show }}
40
+ </MButton>
41
+ </div>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { computed, ref } from 'vue';
46
+ import CrossCircleFilled24 from '@mozaic-ds/icons-vue/src/components/CrossCircleFilled24/CrossCircleFilled24.vue';
47
+ import MButton from '../button/MButton.vue';
48
+
49
+ /**
50
+ * A password input is a specialized input field used to securely enter and manage passwords. It typically masks the characters entered to protect sensitive information from being seen. It includes a toggle button to show or hide the password, improving usability while maintaining security. Password inputs are commonly used in login forms, account creation, and authentication flows.
51
+ */
52
+ const props = withDefaults(
53
+ defineProps<{
54
+ /**
55
+ * A unique identifier for the password input element, used to associate the label with the form element.
56
+ */
57
+ id: string;
58
+ /**
59
+ * The name attribute for the password input element, typically used for form submission.
60
+ */
61
+ name?: string;
62
+ /**
63
+ * The current value of the password input field.
64
+ */
65
+ modelValue?: string | number;
66
+ /**
67
+ * A placeholder text to show in the password input when it is empty.
68
+ */
69
+ placeholder?: string;
70
+ /**
71
+ * If `true`, applies an invalid state to the password input.
72
+ */
73
+ isInvalid?: boolean;
74
+ /**
75
+ * If `true`, disables the password input, making it non-interactive.
76
+ */
77
+ disabled?: boolean;
78
+ /**
79
+ * If `true`, the password input is read-only (cannot be edited).
80
+ */
81
+ readonly?: boolean;
82
+ /**
83
+ * If `true`, a clear button will appear when the password input has a value.
84
+ */
85
+ isClearable?: boolean;
86
+ /**
87
+ * The label text for the clear button
88
+ */
89
+ clearLabel?: string;
90
+ /**
91
+ * Labels of the button displayed when showing or hiding the password
92
+ */
93
+ buttonLabel?: {
94
+ show: string;
95
+ hide: string;
96
+ };
97
+ }>(),
98
+ {
99
+ clearLabel: 'Clear content',
100
+ buttonLabel: () => ({ show: 'Show', hide: 'Hide' }),
101
+ },
102
+ );
103
+
104
+ const classObject = computed(() => ({
105
+ 'is-invalid': props.isInvalid,
106
+ }));
107
+
108
+ // Local state management
109
+ const modelValue = ref(props.modelValue);
110
+ const isVisible = ref(false);
111
+
112
+ /**
113
+ * Clear the input value.
114
+ */
115
+ const clearValue = () => {
116
+ modelValue.value = '';
117
+ emit('update:modelValue', '');
118
+ };
119
+
120
+ /**
121
+ * Toggle the visibility of the password.
122
+ */
123
+ const toggleVisibility = () => {
124
+ isVisible.value = !isVisible.value;
125
+ };
126
+
127
+ /**
128
+ * Compute the input type based on visibility state.
129
+ */
130
+ const inputType = computed(() => (isVisible.value ? 'text' : 'password'));
131
+
132
+ /**
133
+ * Aria attributes for accessibility.
134
+ */
135
+ const ariaChecked = computed(() => (isVisible.value ? 'true' : 'false'));
136
+
137
+ const emit = defineEmits<{
138
+ /**
139
+ * Emits when the input value changes, updating the `modelValue` prop.
140
+ */
141
+ (on: 'update:modelValue', value: string | number): void;
142
+ }>();
143
+ </script>
144
+
145
+ <style lang="scss" scoped>
146
+ @use '@mozaic-ds/styles/components/controls-options';
147
+ @use '@mozaic-ds/styles/components/text-input';
148
+ @use '@mozaic-ds/styles/components/password-input';
149
+ </style>
@@ -10,7 +10,7 @@ const meta: Meta<typeof MQuantitySelector> = {
10
10
  docs: {
11
11
  description: {
12
12
  component:
13
- 'The quantity selector is a form element used to enter or select a number. This type of input is best used when the user needs to choose the quantity of a selected item, like a product before adding to cart for example.',
13
+ 'A quantity selector is an input component that allows users to increment or decrement a numeric value, typically using plus (+) and minus (−) buttons. It provides a simple and efficient way to adjust quantities without manual typing, ensuring controlled input. This component is commonly used in e-commerce, inventory management, and settings where users need to specify amounts.',
14
14
  },
15
15
  },
16
16
  },
@@ -10,7 +10,7 @@ const meta: Meta<typeof MRadio> = {
10
10
  docs: {
11
11
  description: {
12
12
  component:
13
- 'A radio button is used to offer a unique choice to your user in a form. Unlike checkboxes, it can not be used alone.',
13
+ 'A radio button is a selection control that allows users to choose a single option from a list of mutually exclusive choices. Unlike checkboxes, only one option can be selected at a time within the same group. Radio Buttons are commonly used in forms, surveys, and settings where a single choice must be made.',
14
14
  },
15
15
  },
16
16
  },
@@ -10,7 +10,7 @@ const meta: Meta<typeof MRadioGroup> = {
10
10
  docs: {
11
11
  description: {
12
12
  component:
13
- 'A radio button is used to offer a unique choice to your user in a form. Unlike checkboxes, it can not be used alone.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field Group section](/docs/form-elements-field-group--docs#radio%20group).',
13
+ 'A radio button is a selection control that allows users to choose a single option from a list of mutually exclusive choices. Unlike checkboxes, only one option can be selected at a time within the same group. Radio Buttons are commonly used in forms, surveys, and settings where a single choice must be made.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field Group section](/docs/form-elements-field-group--docs#radio-group).',
14
14
  },
15
15
  },
16
16
  },
@@ -10,7 +10,7 @@ const meta: Meta<typeof MSelect> = {
10
10
  docs: {
11
11
  description: {
12
12
  component:
13
- 'A select is a form element for multi-line text input, ideal for longer content like comments or descriptions.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field section](/docs/form-elements-field--docs#select).',
13
+ 'A select component allows users to choose a single option from a predefined list within a native dropdown menu. It helps simplify input by displaying only relevant choices, reducing the need for manual text entry. Select components are commonly used in forms, settings, and filters where structured selection is required.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field section](/docs/form-elements-field--docs#select).',
14
14
  },
15
15
  },
16
16
  },
@@ -29,17 +29,17 @@ type Story = StoryObj<typeof MStatusBadge>;
29
29
  export const Info: Story = {};
30
30
 
31
31
  export const Success: Story = {
32
- args: { appearance: 'success' },
32
+ args: { status: 'success' },
33
33
  };
34
34
 
35
35
  export const Warning: Story = {
36
- args: { appearance: 'warning' },
36
+ args: { status: 'warning' },
37
37
  };
38
38
 
39
- export const Danger: Story = {
40
- args: { appearance: 'danger' },
39
+ export const Error: Story = {
40
+ args: { status: 'error' },
41
41
  };
42
42
 
43
43
  export const Neutral: Story = {
44
- args: { appearance: 'neutral' },
44
+ args: { status: 'neutral' },
45
45
  };
@@ -1,13 +1,13 @@
1
1
  <template>
2
2
  <div class="mc-status-badge" :class="classObject">
3
- <MStatusDot :appearance="appearance" />
3
+ <MStatusDot :status="status" />
4
4
  <span class="mc-status-badge__label">{{ label }}</span>
5
5
  </div>
6
6
  </template>
7
7
 
8
8
  <script setup lang="ts">
9
9
  import { computed } from 'vue';
10
- import MStatusDot from './MStatusDot.vue';
10
+ import MStatusDot from '../statusdot/MStatusDot.vue';
11
11
  /**
12
12
  * A status badge indicates the status of an entity and can evolve at any time.
13
13
  */
@@ -20,17 +20,17 @@ const props = withDefaults(
20
20
  /**
21
21
  * Allows to define the Status Badge style
22
22
  */
23
- appearance?: 'info' | 'success' | 'warning' | 'danger' | 'neutral';
23
+ status?: 'info' | 'success' | 'warning' | 'error' | 'neutral';
24
24
  }>(),
25
25
  {
26
- appearance: 'info',
26
+ status: 'info',
27
27
  },
28
28
  );
29
29
 
30
30
  const classObject = computed(() => {
31
31
  return {
32
- [`mc-status-badge--${props.appearance}`]:
33
- props.appearance && props.appearance != 'info',
32
+ [`mc-status-badge--${props.status}`]:
33
+ props.status && props.status != 'info',
34
34
  };
35
35
  });
36
36
  </script>
@@ -0,0 +1,51 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect } from 'vitest';
3
+ import MStatusDot from './MStatusDot.vue';
4
+
5
+ describe('MStatusDot.vue', () => {
6
+ it('renders with default status and size', () => {
7
+ const wrapper = mount(MStatusDot);
8
+
9
+ expect(wrapper.classes()).toContain('mc-status-dot');
10
+ });
11
+
12
+ it('renders with custom status', () => {
13
+ const wrapper = mount(MStatusDot, {
14
+ props: {
15
+ status: 'success',
16
+ },
17
+ });
18
+
19
+ expect(wrapper.classes()).toContain('mc-status-dot--success');
20
+ });
21
+
22
+ it('renders with custom size', () => {
23
+ const wrapper = mount(MStatusDot, {
24
+ props: {
25
+ size: 's',
26
+ },
27
+ });
28
+
29
+ expect(wrapper.classes()).toContain('mc-status-dot--s');
30
+ });
31
+
32
+ it('does not render the "info" status when a custom one is passed', () => {
33
+ const wrapper = mount(MStatusDot, {
34
+ props: {
35
+ status: 'warning',
36
+ },
37
+ });
38
+
39
+ expect(wrapper.classes()).not.toContain('mc-status-dot--info');
40
+ });
41
+
42
+ it('does not render the "m" size when a custom one is passed', () => {
43
+ const wrapper = mount(MStatusDot, {
44
+ props: {
45
+ size: 'l',
46
+ },
47
+ });
48
+
49
+ expect(wrapper.classes()).not.toContain('mc-status-dot--m');
50
+ });
51
+ });
@@ -0,0 +1,48 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import MStatusDot from './MStatusDot.vue';
3
+
4
+ const meta: Meta<typeof MStatusDot> = {
5
+ title: 'Status/Status Dot',
6
+ component: MStatusDot,
7
+ parameters: {
8
+ docs: {
9
+ description: {
10
+ component:
11
+ 'A Status dot is a small visual indicator used to represent the state or condition of an element. It is often color-coded to convey different statuses at a glance, such as availability, activity, or urgency. Status Dots are commonly found in user presence indicators, system statuses, or process tracking to provide quick, unobtrusive feedback.',
12
+ },
13
+ },
14
+ },
15
+ render: (args) => ({
16
+ components: { MStatusDot },
17
+ setup() {
18
+ return { args };
19
+ },
20
+ template: `
21
+ <MStatusDot v-bind="args"></MStatusDot>
22
+ `,
23
+ }),
24
+ };
25
+ export default meta;
26
+ type Story = StoryObj<typeof MStatusDot>;
27
+
28
+ export const Info: Story = {};
29
+
30
+ export const Success: Story = {
31
+ args: { status: 'success' },
32
+ };
33
+
34
+ export const Warning: Story = {
35
+ args: { status: 'warning' },
36
+ };
37
+
38
+ export const Error: Story = {
39
+ args: { status: 'error' },
40
+ };
41
+
42
+ export const Neutral: Story = {
43
+ args: { status: 'neutral' },
44
+ };
45
+
46
+ export const Size: Story = {
47
+ args: { size: 'l' },
48
+ };
@@ -12,17 +12,21 @@ const props = withDefaults(
12
12
  /**
13
13
  * Allows to define the Status Dot style
14
14
  */
15
- appearance?: 'info' | 'success' | 'warning' | 'danger' | 'neutral';
15
+ status?: 'info' | 'success' | 'warning' | 'error' | 'neutral';
16
+ /**
17
+ * Determines the size of the Status Dot.
18
+ */
19
+ size?: 's' | 'm' | 'l';
16
20
  }>(),
17
21
  {
18
- appearance: 'info',
22
+ status: 'info',
19
23
  },
20
24
  );
21
25
 
22
26
  const classObject = computed(() => {
23
27
  return {
24
- [`mc-status-dot--${props.appearance}`]:
25
- props.appearance && props.appearance != 'info',
28
+ [`mc-status-dot--${props.status}`]: props.status && props.status != 'info',
29
+ [`mc-status-dot--${props.size}`]: props.size && props.size != 'm',
26
30
  };
27
31
  });
28
32
  </script>
@@ -0,0 +1,99 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect } from 'vitest';
3
+ import MStatusNotification from './MStatusNotification.vue';
4
+ import InfoCircle32 from '@mozaic-ds/icons-vue/src/components/InfoCircle32/InfoCircle32.vue';
5
+ import CheckCircle32 from '@mozaic-ds/icons-vue/src/components/CheckCircle32/CheckCircle32.vue';
6
+ import WarningCircle32 from '@mozaic-ds/icons-vue/src/components/WarningCircle32/WarningCircle32.vue';
7
+ import CrossCircle32 from '@mozaic-ds/icons-vue/src/components/CrossCircle32/CrossCircle32.vue';
8
+
9
+ describe('MStatusNotification.vue', () => {
10
+ it('should render correctly with the default props', () => {
11
+ const wrapper = mount(MStatusNotification, {
12
+ props: {
13
+ title: 'Test Title',
14
+ description: 'Test Description',
15
+ },
16
+ });
17
+
18
+ expect(wrapper.text()).toContain('Test Title');
19
+ expect(wrapper.text()).toContain('Test Description');
20
+ expect(wrapper.findComponent(InfoCircle32).exists()).toBe(true); // Default icon is InfoCircle32
21
+ expect(wrapper.classes()).toContain('mc-status-notification');
22
+ });
23
+
24
+ it('should display the correct icon based on the status prop', () => {
25
+ const wrapperSuccess = mount(MStatusNotification, {
26
+ props: {
27
+ title: 'Success',
28
+ description: 'Success Description',
29
+ status: 'success',
30
+ },
31
+ });
32
+ expect(wrapperSuccess.findComponent(CheckCircle32).exists()).toBe(true);
33
+
34
+ const wrapperWarning = mount(MStatusNotification, {
35
+ props: {
36
+ title: 'Warning',
37
+ description: 'Warning Description',
38
+ status: 'warning',
39
+ },
40
+ });
41
+ expect(wrapperWarning.findComponent(WarningCircle32).exists()).toBe(true);
42
+
43
+ const wrapperError = mount(MStatusNotification, {
44
+ props: {
45
+ title: 'Error',
46
+ description: 'Error Description',
47
+ status: 'error',
48
+ },
49
+ });
50
+ expect(wrapperError.findComponent(CrossCircle32).exists()).toBe(true);
51
+ });
52
+
53
+ it('should show the close button if closable prop is true', () => {
54
+ const wrapper = mount(MStatusNotification, {
55
+ props: {
56
+ title: 'Closable Test',
57
+ description: 'Test Description',
58
+ closable: true,
59
+ },
60
+ });
61
+
62
+ expect(
63
+ wrapper.find('button.mc-status-notification-closable__close').exists(),
64
+ ).toBe(true);
65
+ });
66
+
67
+ it('should emit a close event when the close button is clicked', async () => {
68
+ const wrapper = mount(MStatusNotification, {
69
+ props: {
70
+ title: 'Closable Test',
71
+ description: 'Test Description',
72
+ closable: true,
73
+ },
74
+ });
75
+
76
+ const closeButton = wrapper.find(
77
+ 'button.mc-status-notification-closable__close',
78
+ );
79
+ await closeButton.trigger('click');
80
+
81
+ // Check if the "close" event was emitted
82
+ expect(wrapper.emitted()).toHaveProperty('close');
83
+ });
84
+
85
+ it('should render footer slot if provided', () => {
86
+ const footerSlotContent = '<button>Footer Button</button>';
87
+ const wrapper = mount(MStatusNotification, {
88
+ props: {
89
+ title: 'With Footer',
90
+ description: 'Description with footer',
91
+ },
92
+ slots: {
93
+ footer: footerSlotContent,
94
+ },
95
+ });
96
+
97
+ expect(wrapper.html()).toContain(footerSlotContent);
98
+ });
99
+ });
@@ -0,0 +1,96 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import MStatusNotification from './MStatusNotification.vue';
3
+ import { action } from '@storybook/addon-actions';
4
+ import MButton from '../button/MButton.vue';
5
+ import MLink from '../link/MLink.vue';
6
+ import ArrowNext20 from '@mozaic-ds/icons-vue/src/components/ArrowNext20/ArrowNext20.vue';
7
+
8
+ const meta: Meta<typeof MStatusNotification> = {
9
+ title: 'Status/Status Notification',
10
+ component: MStatusNotification,
11
+ parameters: {
12
+ docs: {
13
+ description: {
14
+ component:
15
+ 'A Status Notification is used to draw the user’s attention to important information that needs to be acknowledged. It often provides feedback on a process, highlights a status update, or alerts users about an issue. Notifications are typically triggered by user actions or system events and are designed to be easily noticeable while maintaining a non-intrusive experience.',
16
+ },
17
+ },
18
+ },
19
+ args: {
20
+ title:
21
+ 'This is a title, be concise and use the description message to give details.',
22
+ description: 'Description message.',
23
+ },
24
+ argTypes: {
25
+ $slots: {
26
+ table: {
27
+ disable: true,
28
+ },
29
+ },
30
+ },
31
+ render: (args) => ({
32
+ components: { MStatusNotification, MButton, MLink, ArrowNext20 },
33
+ setup() {
34
+ const handleClick = action('close');
35
+
36
+ return { args, handleClick };
37
+ },
38
+ template: `
39
+ <MStatusNotification
40
+ v-bind="args"
41
+ @click="handleClick"
42
+ >
43
+ <template v-if="${'footer' in args}" v-slot:footer>${args.footer}</template>
44
+ </MStatusNotification>
45
+ `,
46
+ }),
47
+ };
48
+ export default meta;
49
+ type Story = StoryObj<typeof MStatusNotification>;
50
+
51
+ export const Info: Story = {};
52
+
53
+ export const Success: Story = {
54
+ args: { status: 'success' },
55
+ };
56
+
57
+ export const Warning: Story = {
58
+ args: { status: 'warning' },
59
+ };
60
+
61
+ export const Error: Story = {
62
+ args: { status: 'error' },
63
+ };
64
+
65
+ export const Closable: Story = {
66
+ args: { closable: true },
67
+ };
68
+
69
+ export const WithButton = {
70
+ args: {
71
+ footer: `
72
+ <MButton outlined>Button Label</MButton>
73
+ `,
74
+ },
75
+ };
76
+
77
+ export const WithLink = {
78
+ args: {
79
+ footer: `
80
+ <MLink href="#" iconPosition="right">
81
+ Stand-alone link
82
+
83
+ <template #icon><ArrowNext20 /></template>
84
+ </MLink>
85
+ `,
86
+ },
87
+ };
88
+
89
+ export const WithButtons = {
90
+ args: {
91
+ footer: `
92
+ <MButton>Button Label</MButton>
93
+ <MButton outlined>Button Label</MButton>
94
+ `,
95
+ },
96
+ };
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <section class="mc-status-notification" role="status" :class="classObject">
3
+ <component
4
+ :is="iconComponent"
5
+ class="mc-status-notification__icon"
6
+ aria-hidden="true"
7
+ />
8
+ <div class="mc-status-notification__content">
9
+ <h2 class="mc-status-notification__title">{{ title }}</h2>
10
+
11
+ <p class="mc-status-notification__message">
12
+ {{ description }}
13
+ </p>
14
+
15
+ <div v-if="$slots.footer" class="mc-status-notification__footer">
16
+ <slot name="footer" />
17
+ </div>
18
+ </div>
19
+
20
+ <button
21
+ v-if="closable"
22
+ class="mc-status-notification-closable__close"
23
+ @click="emit('close')"
24
+ >
25
+ <Cross20
26
+ class="mc-status-notification-closable__icon"
27
+ aria-hidden="true"
28
+ />
29
+ <span class="mc-status-notification-closable__text">Close</span>
30
+ </button>
31
+ </section>
32
+ </template>
33
+
34
+ <script setup lang="ts">
35
+ import { computed, type VNode } from 'vue';
36
+ import Cross20 from '@mozaic-ds/icons-vue/src/components/Cross20/Cross20.vue';
37
+ import InfoCircle32 from '@mozaic-ds/icons-vue/src/components/InfoCircle32/InfoCircle32.vue';
38
+ import WarningCircle32 from '@mozaic-ds/icons-vue/src/components/WarningCircle32/WarningCircle32.vue';
39
+ import CrossCircle32 from '@mozaic-ds/icons-vue/src/components/CrossCircle32/CrossCircle32.vue';
40
+ import CheckCircle32 from '@mozaic-ds/icons-vue/src/components/CheckCircle32/CheckCircle32.vue';
41
+ /**
42
+ * A Status Notification is used to draw the user’s attention to important information that needs to be acknowledged. It often provides feedback on a process, highlights a status update, or alerts users about an issue. Notifications are typically triggered by user actions or system events and are designed to be easily noticeable while maintaining a non-intrusive experience.
43
+ */
44
+ const props = withDefaults(
45
+ defineProps<{
46
+ /**
47
+ * Title of the Status Notification
48
+ */
49
+ title: string;
50
+ /**
51
+ * Description of the Status Notification
52
+ */
53
+ description: string;
54
+ /**
55
+ * Allows to define the Status Notification style
56
+ */
57
+ status?: 'info' | 'success' | 'warning' | 'error';
58
+ /**
59
+ * if `true`, display the close button.
60
+ */
61
+ closable?: boolean;
62
+ }>(),
63
+ {
64
+ status: 'info',
65
+ },
66
+ );
67
+
68
+ defineSlots<{
69
+ /**
70
+ * Use this slot to insert a button or a link in the footer
71
+ */
72
+ footer?: VNode;
73
+ }>();
74
+
75
+ const classObject = computed(() => {
76
+ return {
77
+ [`mc-status-notification--${props.status}`]:
78
+ props.status && props.status != 'info',
79
+ };
80
+ });
81
+
82
+ const iconComponent = computed(() => {
83
+ switch (props.status) {
84
+ case 'success':
85
+ return CheckCircle32;
86
+ case 'warning':
87
+ return WarningCircle32;
88
+ case 'error':
89
+ return CrossCircle32;
90
+ case 'info':
91
+ default:
92
+ return InfoCircle32;
93
+ }
94
+ });
95
+
96
+ const emit = defineEmits<{
97
+ /**
98
+ * Emits when closing the notification.
99
+ */
100
+ (on: 'close'): void;
101
+ }>();
102
+ </script>
103
+
104
+ <style lang="scss" scoped>
105
+ @use '@mozaic-ds/styles/components/status-notification';
106
+ </style>