import type { Meta, StoryFn } from '@storybook/vue3-vite';
import { ref } from 'vue';
import UIRadioButton from '@/UI-kit/components/UI/radio-button/UIRadioButton.vue';

export default {
    title: 'UI/UIRadioButton',
    component: UIRadioButton,
    argTypes: {
        modelValue: { control: false },
        name: { control: 'text' },
        options: {
            control: 'object',
        },
    },
} as Meta<typeof UIRadioButton>;

export const Default: StoryFn<typeof UIRadioButton> = (args) => ({
    components: { UIRadioButton },
    setup() {
        const value = ref(args.modelValue);

        return {
            args,
            value,
        };
    },
    template: `
        <UIRadioButton
            v-bind="args"
            :modelValue="value"
            @update:modelValue="value = $event"
        />
        <p>Selected: {{ value }}</p>
    `,
});

Default.args = {
    modelValue: 'option1',
    name: 'example-group',
    options: [
        { label: 'Option 1', value: 'option1' },
        { label: 'Option 2', value: 'option2' },
        { label: 'Option 3', value: 'option3' },
    ],
};
