import type { Meta, StoryObj } from '@storybook/vue3-vite';
import { action } from 'storybook/actions';

import MSegmentedControl from './MSegmentedControl.vue';

const meta: Meta<typeof MSegmentedControl> = {
  title: 'Action/Segmented Control',
  component: MSegmentedControl,
  parameters: {
    docs: {
      description: {
        component:
          'A Segmented Control allows users to switch between multiple options or views within a single container. It provides a compact and efficient way to toggle between sections without requiring a dropdown or separate navigation. Segmented Controls are commonly used in filters, tabbed navigation, and content selection to enhance user interaction and accessibility.',
      },
    },
  },
  args: {
    modelValue: 'label1',
    segments: [
      {
        id: 'label1',
        label: 'Label',
      },
      {
        id: 'label2',
        label: 'Label',
      },
      {
        id: 'label3',
        label: 'Label',
      },
      {
        id: 'label4',
        label: 'Label',
      },
    ],
  },
  render: (args) => ({
    components: { MSegmentedControl },
    setup() {
      const handleUpdate = action('update:modelValue');

      return { args, handleUpdate };
    },
    template: `
      <MSegmentedControl
        v-bind="args"
        v-model="args.modelValue"
        @update:modelValue="handleUpdate"
      ></MSegmentedControl>
    `,
  }),
};
export default meta;
type Story = StoryObj<typeof MSegmentedControl>;

export const Default: Story = {};

export const Size: Story = {
  args: { size: 'm' },
};

export const Full: Story = {
  args: { full: true },
};
