feat: composant saisie assistée, composant téléphone et composant mail (#47)
All checks were successful
Release / release (push) Successful in 1m12s

| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
|                  |                 |

## Description de la PR

## Modification du .env

## Check list

- [ ] Pas de régression
- [ ] TU/TI/TF rédigée
- [ ] TU/TI/TF OK
- [ ] CHANGELOG modifié

Co-authored-by: matthieu <matthieu@yuno.malio.fr>
Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr>
Reviewed-on: #47
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #47.
This commit is contained in:
2026-05-13 07:01:30 +00:00
committed by Autin
parent d9023a0ddc
commit f3a18ace1d
33 changed files with 4040 additions and 151 deletions

View File

@@ -153,4 +153,33 @@ describe('MalioRadioButton', () => {
expect(wrapper.get('input').classes()).toContain('border-red-500')
expect(wrapper.get('.radio-text').classes()).toContain('font-bold')
})
it('uses muted label color and muted border when unchecked', () => {
const wrapper = mountRadioButton({label: 'Option 1', value: 'a', modelValue: 'b'})
expect(wrapper.get('.radio-text').classes()).toContain('text-m-muted')
expect(wrapper.get('input').classes()).toContain('border-m-muted')
})
it('uses black label color when checked', () => {
const wrapper = mountRadioButton({label: 'Option 1', value: 'a', modelValue: 'a'})
expect(wrapper.get('.radio-text').classes()).toContain('text-black')
})
it('has checked:border-black on input', () => {
const wrapper = mountRadioButton({label: 'Option 1', value: 'a', modelValue: 'a'})
expect(wrapper.get('input').classes()).toContain('checked:border-black')
})
it('updates label color when toggled without v-model (uncontrolled)', async () => {
const wrapper = mountRadioButton({label: 'Option 1', value: 'a'})
expect(wrapper.get('.radio-text').classes()).toContain('text-m-muted')
await wrapper.get('input').trigger('change')
expect(wrapper.get('.radio-text').classes()).toContain('text-black')
})
})

View File

@@ -44,7 +44,7 @@
</template>
<script setup lang="ts">
import {computed, useAttrs, useId} from 'vue'
import {computed, ref, useAttrs, useId} from 'vue'
import {twMerge} from 'tailwind-merge'
defineOptions({name: 'MalioRadioButton', inheritAttrs: false})
@@ -86,9 +86,13 @@ const props = withDefaults(
const attrs = useAttrs()
const generatedId = useId()
const localValue = ref<string | number | boolean | null | undefined>(undefined)
const inputId = computed(() => props.id?.toString() || `malio-radio-${generatedId}`)
const isChecked = computed(() => props.modelValue === props.value)
const isControlled = computed(() => props.modelValue !== undefined)
const isChecked = computed(() =>
isControlled.value ? props.modelValue === props.value : localValue.value === props.value,
)
const hasError = computed(() => !!props.error)
const hasSuccess = computed(() => !!props.success && !hasError.value)
const disabled = computed(() => props.disabled)
@@ -117,14 +121,15 @@ const mergedControlClass = computed(() =>
const mergedInputClass = computed(() =>
twMerge(
'h-5 w-5 cursor-pointer appearance-none rounded-full border-2 border-black',
'h-5 w-5 cursor-pointer appearance-none rounded-full border-2 border-m-muted checked:border-black',
props.inputClass,
),
)
const mergedLabelClass = computed(() =>
twMerge(
'radio-text mt-px cursor-pointer text-black',
'radio-text mt-px cursor-pointer',
isChecked.value ? 'text-black' : 'text-m-muted',
hasError.value ? 'text-m-danger' : '',
hasSuccess.value ? 'text-m-success' : '',
disabled.value ? 'cursor-not-allowed text-black/60' : '',
@@ -160,6 +165,10 @@ const onChange = (event: Event) => {
return
}
if (!isControlled.value) {
localValue.value = props.value
}
emit('update:modelValue', props.value)
}
</script>