import type { Meta, StoryObj } from '@storybook/react-webpack5';
import { useState } from 'react';
import { fn } from 'storybook/test';
import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
title: 'Example/RenameDialog',
component: RenameDialog,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
docs: {
description: {
component: `
## Component Description
RenameDialog is a modal dialog component for renaming items. It provides a form with input validation and loading states, commonly used in chat applications for renaming conversations or creating new ones.
### Features
- Modal dialog with form input
- Loading state support
- Customizable title
- Initial name pre-filling
- Form validation and submission
### Import Path
\`\`\`tsx
import { RenameDialog } from '@/components/rename-dialog';
\`\`\`
### Basic Usage
\`\`\`tsx
import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { useState } from 'react';
function MyComponent() {
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
return (
);
}
\`\`\`
`,
},
},
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
argTypes: {
initialName: {
control: 'text',
description: 'Initial name value for the input field',
},
title: {
control: 'text',
description: 'Custom title for the dialog',
},
loading: {
control: 'boolean',
description: 'Loading state of the save button',
},
},
// Use `fn` to spy on the args, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
args: {
hideModal: fn(),
onOk: fn(),
},
} satisfies Meta;
export default meta;
type Story = StoryObj;
// Story components to handle useState hooks
const DefaultStoryComponent = (args: any) => {
const [visible, setVisible] = useState(false);
return (