aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/StudipRadioButtonGroup.vue
blob: e5fd5e756683f67673d6f6be0a5d64d6eedb2f1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<script setup lang="ts">
import {computed, onMounted} from "vue";
import StudipRadioButton from "./StudipRadioButton.vue";

const props = defineProps<{
    label: string;
    modelValue: string | number | boolean;
    name: string;
    options: Record<string, string>
}>();

const emit = defineEmits(['update:modelValue']);

const model = computed({
    get() {
        return props.modelValue;
    },
    set(newValue) {
        emit('update:modelValue', newValue);
    }
})

onMounted(() => {
    document.addEventListener('focusin', event => console.log('focussed', event.target), {capture: true})
})

</script>
<template>
    <div role="radiogroup"
         :aria-label="props.label"
    >
        <StudipRadioButton v-for="(optionLabel, key) in options"
                           :key="key"
                           :value="key"
                           :name="name"
                           v-model="model"
        >
            {{ optionLabel }}
        </StudipRadioButton>

    </div>
</template>