feat(ui): astérisque required dans le label de la famille formulaire

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 11:45:48 +02:00
parent 61cb90a9c6
commit 120020b210
26 changed files with 157 additions and 13 deletions
@@ -173,6 +173,16 @@ describe('MalioRadioButton', () => {
expect(wrapper.get('input').classes()).toContain('checked:border-black')
})
it('affiche l\'astérisque quand required est vrai', () => {
const wrapper = mountRadioButton({label: 'Champ', required: true})
expect(wrapper.find('[data-test="required-mark"]').exists()).toBe(true)
})
it('n\'affiche pas l\'astérisque par défaut', () => {
const wrapper = mountRadioButton({label: 'Champ'})
expect(wrapper.find('[data-test="required-mark"]').exists()).toBe(false)
})
it('updates label color when toggled without v-model (uncontrolled)', async () => {
const wrapper = mountRadioButton({label: 'Option 1', value: 'a'})
+2 -1
View File
@@ -29,7 +29,7 @@
:for="inputId"
:class="mergedLabelClass"
>
{{ label }}
{{ label }}<MalioRequiredMark v-if="required" />
</label>
</div>
@@ -46,6 +46,7 @@
<script setup lang="ts">
import {computed, ref, useAttrs, useId} from 'vue'
import {twMerge} from 'tailwind-merge'
import MalioRequiredMark from '../shared/RequiredMark.vue'
defineOptions({name: 'MalioRadioButton', inheritAttrs: false})