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>
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { DatePicker } from './date-picker';
|
|
import { useState } from 'react';
|
|
|
|
const meta: Meta = {
|
|
title: 'UI/DatePicker',
|
|
component: DatePicker,
|
|
tags: ['autodocs'],
|
|
argTypes: {
|
|
mode: {
|
|
control: 'radio',
|
|
options: ['single', 'range'],
|
|
},
|
|
disabled: { control: 'boolean' },
|
|
placeholder: { control: 'text' },
|
|
},
|
|
args: {
|
|
mode: 'single',
|
|
placeholder: 'Pick a date',
|
|
}
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const SingleDate: Story = {
|
|
render: (args) => {
|
|
const [date, setDate] = useState<Date>();
|
|
return (
|
|
<DatePicker
|
|
{...args}
|
|
value={date}
|
|
onChange={(newDate) => setDate(newDate as Date)}
|
|
className="w-72"
|
|
/>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const DateRange: Story = {
|
|
args: {
|
|
mode: 'range',
|
|
placeholder: 'Select range',
|
|
},
|
|
render: (args) => {
|
|
const [range, setRange] = useState<{ start: Date; end: Date }>();
|
|
return (
|
|
<DatePicker
|
|
{...args}
|
|
value={range}
|
|
onChange={(newRange) => setRange(newRange as { start: Date; end: Date })}
|
|
className="w-80"
|
|
/>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const Disabled: Story = {
|
|
args: {
|
|
disabled: true,
|
|
},
|
|
render: (args) => <DatePicker {...args} onChange={() => { }} className="w-72" />,
|
|
};
|