veza/apps/web/src/components/ui/FocusTrap.stories.tsx
senke 0a29c544af fix(web): resolve all 568 TypeScript errors — tsc --noEmit now passes with zero errors
Major categories fixed:
- TS6133 (188): Remove unused imports (React, icons, types) and variables
- TS2322 (222): Fix type mismatches in stories (satisfies Meta -> const meta: Meta),
  add nullish coalescing for optional values, fix component prop types
- TS2345 (43): Fix argument type mismatches with proper null checks and type narrowing
- TS2741 (21): Add missing required properties to mock/story data
- TS2339 (19): Fix property access on incorrect types, add type guards
- TS2353 (13): Remove extra properties from object literals or extend interfaces
- TS2352 (11): Fix type conversion chains
- TS2307 (9): Fix import paths and module references
- Other (42): Fix implicit any, possibly undefined, export declarations

Vite build and tsc --noEmit both pass cleanly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 00:32:08 +01:00

57 lines
2.2 KiB
TypeScript

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: Meta = {
title: 'UI/FocusTrap',
component: FocusTrap,
tags: ['autodocs'],
argTypes: {
active: { control: 'boolean' },
},
};
export default meta;
type Story = StoryObj<typeof meta>;
export const Interactive: Story = {
render: (args) => {
const [active, setActive] = useState(false);
return (
<div className="space-y-4">
<Button onClick={() => setActive(!active)}>
{active ? 'Disable Focus Trap' : 'Enable Focus Trap'}
</Button>
<div className={`p-6 border rounded-lg transition-colors ${active ? 'border-primary bg-card' : 'border-border'}`}>
<h3 className="mb-4 font-bold">{active ? 'Focus Trapped Here' : 'Normal Navigation'}</h3>
<FocusTrap {...args} active={active} onEscape={() => setActive(false)}>
<div className="space-y-4">
<Input placeholder="First focusable element" />
<div className="flex gap-2">
<Button variant="outline">Button 1</Button>
<Button variant="destructive">Button 2</Button>
</div>
<Input placeholder="Last focusable element" />
</div>
</FocusTrap>
{active && (
<p className="mt-4 text-sm text-muted-foreground">
Try tabbing through inputs. Focus should stay within this box. Press Escape to exit.
</p>
)}
</div>
<div className="p-4 border border-dashed border-border opacity-50">
<p>Elements outside trap (cannot reach freely when active)</p>
<Button variant="ghost" className="mt-2">Outside Button</Button>
</div>
</div>
);
},
};