import React, { useCallback, useEffect, useState } from 'react'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import { Box } from '../Layout'; import { Text } from '../Text'; import { Tabs } from '.'; export default { title: 'UI Components/Tabs', component: Tabs.Root, argTypes: { value: { control: { type: 'text' }, defaultValue: 'tab1' }, onValueChange: { action: { type: 'click' } }, orientation: { options: ['horizontal', 'vertical'], defaultValue: 'horizontal', control: { type: 'select' } }, }, } as ComponentMeta; const Template: ComponentStory = ({ value: propValue = '', onValueChange: propOnValueChange, ...rest }) => { const [value, setValue] = useState('tab1'); const handleOnValueChange = useCallback( (value: string) => { setValue(value); if (propOnValueChange) { propOnValueChange(value); } }, [propOnValueChange], ); useEffect(() => { handleOnValueChange(propValue); if (propOnValueChange) { propOnValueChange(value); } }, [handleOnValueChange, propOnValueChange, propValue, value]); return ( One Two Three Tab one content Tab two content Tab three content ); }; export const Example = Template.bind({}); Example.storyName = 'Tabs';