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>
70 lines
2 KiB
TypeScript
70 lines
2 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { VirtualizedList } from './virtualized-list';
|
|
|
|
// Generate 1000 items
|
|
interface ListItem {
|
|
id: number;
|
|
text: string;
|
|
description: string;
|
|
}
|
|
|
|
const items: ListItem[] = Array.from({ length: 1000 }, (_, i) => ({
|
|
id: i,
|
|
text: `Item ${i + 1}`,
|
|
description: `This is the description for item ${i + 1}. Scrolling is optimized.`,
|
|
}));
|
|
|
|
const meta = {
|
|
title: 'UI/VirtualizedList',
|
|
component: VirtualizedList,
|
|
tags: ['autodocs'],
|
|
argTypes: {
|
|
itemHeight: { control: 'number' },
|
|
containerHeight: { control: 'number' },
|
|
overscan: { control: 'number' },
|
|
},
|
|
} satisfies Meta;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const Default: Story = {
|
|
args: {
|
|
items,
|
|
itemHeight: 70,
|
|
containerHeight: 400,
|
|
className: 'border border-border rounded-md',
|
|
renderItem: (item: unknown) => {
|
|
const typedItem = item as ListItem;
|
|
return (
|
|
<div
|
|
key={typedItem.id}
|
|
className="h-[70px] p-4 border-b border-border flex flex-col justify-center hover:bg-white/5 transition-colors"
|
|
>
|
|
<span className="font-bold text-foreground">{typedItem.text}</span>
|
|
<span className="text-xs text-muted-foreground">{typedItem.description}</span>
|
|
</div>
|
|
);
|
|
},
|
|
},
|
|
};
|
|
|
|
export const SmallItems: Story = {
|
|
args: {
|
|
items,
|
|
itemHeight: 30,
|
|
containerHeight: 300,
|
|
className: 'border border-border rounded-md',
|
|
renderItem: (item: unknown) => {
|
|
const typedItem = item as ListItem;
|
|
return (
|
|
<div
|
|
key={typedItem.id}
|
|
className="h-[30px] px-4 flex items-center border-b border-white/5 hover:bg-white/5 text-sm"
|
|
>
|
|
{typedItem.text}
|
|
</div>
|
|
);
|
|
},
|
|
},
|
|
};
|