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

const meta: Meta<typeof Component> = {
	component: Component,
	argTypes: {
		label: {
			control: { type: 'text' },
		},
		hint: {
			control: { type: 'text' },
		},
		indicator: {
			control: { type: 'text' },
		},
		variant: {
			control: {
				type: 'select',
			},
			options: TextControl.AVAILABLE_VARIANTS,
		},
		size: {
			control: {
				type: 'select',
			},
			options: TextControl.AVAILABLE_SIZES,
		},
		inputMode: {
			control: {
				type: 'select',
			},
			options: TextControl.AVAILABLE_INPUT_MODES,
		},
		length: {
			control: {
				type: 'number',
			},
		},
		onChange: {
			table: {
				disable: true,
			},
			action: 'changed',
		},
	},
	args: {
		...(Component.defaultProps ?? {}),
		label: Component.displayName,
	},
};

export const PatternTextInput = (args: Omit<Props, 'ref'>) => (
	<Component
		{...args}
	/>
);

export default meta;
