import type { Meta, StoryObj } from '@storybook/react'; import { FocusTrap } from './focus-trap'; import { Button } from './button'; import { Input } from './input'; import { useState } from 'react'; const meta = { title: 'UI/FocusTrap', component: FocusTrap, tags: ['autodocs'], argTypes: { active: { control: 'boolean' }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const Interactive: Story = { render: (args) => { const [active, setActive] = useState(false); return (

{active ? 'Focus Trapped Here' : 'Normal Navigation'}

setActive(false)}>
{active && (

Try tabbing through inputs. Focus should stay within this box. Press Escape to exit.

)}

Elements outside trap (cannot reach freely when active)

); }, };