feature: emit handler added

This commit is contained in:
Paul Valerie GOMA 2025-07-21 16:22:24 +02:00
parent 34427c40a2
commit 4ddb99a878

View File

@ -2,14 +2,37 @@
import Accordion from 'primevue/accordion';
import VAccordionChild from './VAccordionChild.vue';
import type IVAccordion from './IVAccordion.type';
import { ref, watch } from 'vue';
const props = withDefaults(defineProps<IVAccordion>(), {
value: null,
value: null,
});
const emit = defineEmits([
'update:value',
])
const localValue = ref(props.value);
watch(() => props.value, (newVal) => {
if(localValue.value !== newVal) {
localValue.value = newVal;
}
});
watch(localValue, (newVal) => {
if(props.value !== newVal){
emit('update:value', newVal);
}
});
</script>
<template>
<Accordion :value="props.value" class="p-accordion" style="width: 100%;">
<Accordion
v-model:value="localValue"
class="p-accordion"
style="width: 100%;"
@update:value="emit('update:value', $event)"
>
<slot>
<VAccordionChild/>
</slot>