import * as React from 'react';
import type { Meta } from '@storybook/react';
import { Button } from '@tesseract-design/web-base';
import { RadioButton as Component, RadioButtonProps as Props } from '.';

const LENGTH = 3 as const;

const meta: Meta<typeof Component> = {
	component: Component,
	argTypes: {
		badge: {
			control: {
				type: 'text',
			},
		},
		variant: {
			control: { type: 'select' },
			options: Button.AVAILABLE_VARIANTS,
		},
		size: {
			control: { type: 'select' },
			options: Button.AVAILABLE_SIZES,
		},
		subtext: {
			control: { type: 'text' },
		},
		onChange: {
			table: {
				disable: true,
			},
			action: 'changed',
		},
	},
	args: {
		...(Component.defaultProps ?? {}),
	},
};

export const RadioButton = (args: Omit<Props, 'ref'>) => (
	<>
		{Array.from({ length: LENGTH }).map((_, i) => (
			<Component
				{...args}
				key={i}
				name={Component.displayName}
				value={i + 1}
			>
				{Component.displayName} {i + 1}
			</Component>
		))}
	</>
);

export default meta;
