@mozaic-ds/vue 2.15.0 → 2.16.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.
@@ -0,0 +1,57 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import MStepperStacked from './MStepperStacked.vue';
3
+
4
+ const meta: Meta<typeof MStepperStacked> = {
5
+ title: 'Indicators/Stepper Stacked',
6
+ component: MStepperStacked,
7
+ tags: ['v2'],
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component:
12
+ 'A stepper is a navigation component that guides users through a sequence of steps in a structured process. It visually represents progress, completed steps, and upcoming steps, helping users understand their position within a workflow. Steppers are commonly used in multi-step forms, onboarding flows, checkout processes, and task completion sequences to improve clarity and reduce cognitive load.',
13
+ },
14
+ },
15
+ },
16
+ args: {
17
+ currentStep: 1,
18
+ steps: [
19
+ { id: '1', label: 'Cart' },
20
+ { id: '2', label: 'Delivery address' },
21
+ { id: '3', label: 'Payment' },
22
+ { id: '4', label: 'Order confirmation' },
23
+ ],
24
+ },
25
+ render: (args) => ({
26
+ components: { MStepperStacked },
27
+ setup() {
28
+ return { args };
29
+ },
30
+ template: `<MStepperStacked v-bind="args" />`,
31
+ }),
32
+ };
33
+
34
+ export default meta;
35
+ type Story = StoryObj<typeof MStepperStacked>;
36
+
37
+ export const Default: Story = {};
38
+
39
+ export const AditionnalInfo: Story = {
40
+ args: {
41
+ currentStep: 2,
42
+ steps: [
43
+ { id: '1', label: 'Cart', additionalInfo: 'Additional information' },
44
+ {
45
+ id: '2',
46
+ label: 'Delivery address',
47
+ additionalInfo: 'Additional information',
48
+ },
49
+ { id: '3', label: 'Payment', additionalInfo: 'Additional information' },
50
+ {
51
+ id: '4',
52
+ label: 'Order confirmation',
53
+ additionalInfo: 'Additional information',
54
+ },
55
+ ],
56
+ },
57
+ };
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <nav class="mc-stepper-stacked" aria-label="Stepper">
3
+ <ol class="mc-stepper-stacked__container">
4
+ <li
5
+ v-for="(step, index) in steps"
6
+ :key="index"
7
+ :class="{
8
+ 'mc-stepper-stacked__item': true,
9
+ 'has-additional': step.additionalInfo,
10
+ }"
11
+ >
12
+ <div class="mc-stepper-stacked__indicator">
13
+ <Check24
14
+ v-if="stepStates[index].completed"
15
+ class="mc-stepper-stacked__icon mc-stepper-stacked__icon--check"
16
+ />
17
+ <span
18
+ v-else
19
+ :class="{
20
+ 'mc-stepper-stacked__circle': true,
21
+ 'is-current': stepStates[index].current,
22
+ }"
23
+ >
24
+ {{ index + 1 }}
25
+ </span>
26
+ </div>
27
+ <div class="mc-stepper-stacked__content">
28
+ <span
29
+ :class="{
30
+ 'mc-stepper-stacked__label': true,
31
+ 'is-current': stepStates[index].current,
32
+ }"
33
+ >
34
+ {{ step.label }}
35
+ </span>
36
+ <span class="mc-stepper-stacked__additional">
37
+ {{ step.additionalInfo }}
38
+ </span>
39
+ </div>
40
+ </li>
41
+ </ol>
42
+ </nav>
43
+ </template>
44
+
45
+ <script setup lang="ts">
46
+ import { computed } from 'vue';
47
+ import { Check24 } from '@mozaic-ds/icons-vue';
48
+ /**
49
+ * A stepper is a navigation component that guides users through a sequence of steps in a structured process. It visually represents progress, completed steps, and upcoming steps, helping users understand their position within a workflow. Steppers are commonly used in multi-step forms, onboarding flows, checkout processes, and task completion sequences to improve clarity and reduce cognitive load.
50
+ */
51
+ const props = withDefaults(
52
+ defineProps<{
53
+ /**
54
+ * Defines the currently active step.
55
+ *
56
+ * - If a `number` is provided, it represents the 1-based position of the step
57
+ * in the `steps` array (e.g. `1` for the first step).
58
+ * - If a `string` is provided, it must match the `id` of one of the steps.
59
+ */
60
+ currentStep?: string | number;
61
+ /**
62
+ * Steps of the stepper inline.
63
+ */
64
+ steps?: Array<{
65
+ /**
66
+ * Unique identifier for the step.
67
+ */
68
+ id?: string;
69
+ /**
70
+ * Label of the step.
71
+ */
72
+ label: string;
73
+ /**
74
+ * Optional additional information under the label.
75
+ */
76
+ additionalInfo?: string;
77
+ }>;
78
+ }>(),
79
+ {
80
+ currentStep: '1',
81
+ steps: () => [],
82
+ },
83
+ );
84
+
85
+ const activeStep = computed(() => {
86
+ if (typeof props.currentStep === 'number') {
87
+ return Math.min(Math.max(props.currentStep, 1), props.steps.length) - 1;
88
+ } else {
89
+ const activeIndex = props.steps.findIndex(
90
+ (step) => step.id === props.currentStep,
91
+ );
92
+ return activeIndex === -1 ? 0 : activeIndex;
93
+ }
94
+ });
95
+
96
+ const stepStates = computed(() =>
97
+ props.steps.map((_, i) => ({
98
+ completed: i < activeStep.value,
99
+ current: i === activeStep.value,
100
+ })),
101
+ );
102
+ </script>
103
+
104
+ <style scoped lang="scss">
105
+ @use '@mozaic-ds/styles/components/stepper-stacked';
106
+ </style>
@@ -0,0 +1,15 @@
1
+ # MStepperStacked
2
+
3
+ A stepper is a navigation component that guides users through a sequence of steps in a structured process. It visually represents progress, completed steps, and upcoming steps, helping users understand their position within a workflow. Steppers are commonly used in multi-step forms, onboarding flows, checkout processes, and task completion sequences to improve clarity and reduce cognitive load.
4
+
5
+
6
+ ## Props
7
+
8
+ | Name | Description | Type | Default |
9
+ | --- | --- | --- | --- |
10
+ | `currentStep` | Defines the currently active step.
11
+
12
+ - If a `number` is provided, it represents the 1-based position of the step
13
+ in the `steps` array (e.g. `1` for the first step).
14
+ - If a `string` is provided, it must match the `id` of one of the steps. | `string` `number` | `"1"` |
15
+ | `steps` | Steps of the stepper inline. | `{ id?: string` `undefined; label: string; additionalInfo?: string` `undefined; }[]` | `[]` |
@@ -7,6 +7,7 @@
7
7
  <span v-if="prefix" class="mc-text-input__addon">{{ prefix }}</span>
8
8
 
9
9
  <input
10
+ ref="textInput"
10
11
  :id="id"
11
12
  class="mc-text-input__control"
12
13
  :value="modelValue"
@@ -41,7 +42,7 @@
41
42
  </template>
42
43
 
43
44
  <script setup lang="ts">
44
- import { computed, type VNode } from 'vue';
45
+ import { computed, useTemplateRef, type VNode } from 'vue';
45
46
  import { CrossCircleFilled24 } from '@mozaic-ds/icons-vue';
46
47
 
47
48
  /**
@@ -130,6 +131,8 @@ const classObject = computed(() => {
130
131
  };
131
132
  });
132
133
 
134
+ const textInput = useTemplateRef('textInput');
135
+
133
136
  const clearValue = () => {
134
137
  emit('update:modelValue', '');
135
138
  };
@@ -141,9 +144,18 @@ const emit = defineEmits<{
141
144
  (on: 'update:modelValue', value: string | number): void;
142
145
  }>();
143
146
 
147
+ function focus() {
148
+ console.log(textInput.value);
149
+ textInput.value?.focus();
150
+ }
151
+
144
152
  defineOptions({
145
153
  inheritAttrs: false,
146
154
  });
155
+
156
+ defineExpose({
157
+ focus,
158
+ });
147
159
  </script>
148
160
 
149
161
  <style lang="scss" scoped>
@@ -11,7 +11,7 @@ A text input is a single-line input that allows users to enter and edit short te
11
11
  | `name` | The name attribute for the input element, typically used for form submission. | `string` | - |
12
12
  | `modelValue` | The current value of the input field. | `string` `number` | - |
13
13
  | `placeholder` | A placeholder text to show in the input when it is empty. | `string` | - |
14
- | `inputType` | Defines the type of input. | `"number"` `"text"` `"search"` `"date"` `"email"` `"password"` `"tel"` | `"text"` |
14
+ | `inputType` | Defines the type of input. | `"number"` `"search"` `"text"` `"date"` `"email"` `"password"` `"tel"` | `"text"` |
15
15
  | `isInvalid` | If `true`, applies an invalid state to the input. | `boolean` | - |
16
16
  | `disabled` | If `true`, disables the input, making it non-interactive. | `boolean` | - |
17
17
  | `size` | Determines the size of the input. | `"s"` `"m"` | `"m"` |
@@ -32,3 +32,17 @@ A text input is a single-line input that allows users to enter and edit short te
32
32
  | Name | Description | Type |
33
33
  | --- | --- | --- |
34
34
  | `update:modelValue` | Emits when the input value changes, updating the `modelValue` prop. | [value: string | number] |
35
+
36
+ ## Dependencies
37
+
38
+ ### Used By
39
+
40
+ - [MOptionListbox](../optionListbox)
41
+
42
+ ### Graph
43
+
44
+ ```mermaid
45
+ graph TD;
46
+ MOptionListbox --> MTextInput
47
+ style MTextInput fill:#008240,stroke:#333,stroke-width:4px
48
+ ```
package/src/main.ts CHANGED
@@ -12,6 +12,7 @@ export { default as MCheckbox } from './components/checkbox/MCheckbox.vue';
12
12
  export { default as MCheckboxGroup } from './components/checkboxgroup/MCheckboxGroup.vue';
13
13
  export { default as MCheckListMenu } from './components/checklistmenu/MCheckListMenu.vue';
14
14
  export { default as MCircularProgressbar } from './components/circularprogressbar/MCircularProgressbar.vue';
15
+ export { default as MCombobox } from './components/combobox/MCombobox.vue';
15
16
  export { default as MContainer } from './components/container/MContainer.vue';
16
17
  export { default as MDatepicker } from './components/datepicker/MDatepicker.vue';
17
18
  export { default as MDivider } from './components/divider/MDivider.vue';