51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
|
|
import type { Meta, StoryObj } from '@storybook/react';
|
||
|
|
import { FormBuilder, type FormField } from './FormBuilder';
|
||
|
|
|
||
|
|
const sampleFields: FormField[] = [
|
||
|
|
{ name: 'name', type: 'text', label: 'Nom', required: true },
|
||
|
|
{ name: 'email', type: 'email', label: 'Email', required: true },
|
||
|
|
{ name: 'message', type: 'textarea', label: 'Message', placeholder: 'Votre message' },
|
||
|
|
];
|
||
|
|
|
||
|
|
const meta = {
|
||
|
|
title: 'Components/Forms/FormBuilder',
|
||
|
|
component: FormBuilder,
|
||
|
|
tags: ['autodocs'],
|
||
|
|
parameters: { layout: 'padded' },
|
||
|
|
decorators: [
|
||
|
|
(Story) => (
|
||
|
|
<div className="max-w-md">
|
||
|
|
<Story />
|
||
|
|
</div>
|
||
|
|
),
|
||
|
|
],
|
||
|
|
} satisfies Meta<typeof FormBuilder>;
|
||
|
|
|
||
|
|
export default meta;
|
||
|
|
type Story = StoryObj<typeof meta>;
|
||
|
|
|
||
|
|
export const Default: Story = {
|
||
|
|
args: {
|
||
|
|
fields: sampleFields,
|
||
|
|
onSubmit: () => {},
|
||
|
|
submitLabel: 'Envoyer',
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export const Empty: Story = {
|
||
|
|
args: {
|
||
|
|
fields: [],
|
||
|
|
onSubmit: () => {},
|
||
|
|
submitLabel: 'Submit',
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export const Disabled: Story = {
|
||
|
|
args: {
|
||
|
|
fields: sampleFields,
|
||
|
|
onSubmit: () => {},
|
||
|
|
submitLabel: 'Envoyer',
|
||
|
|
disabled: true,
|
||
|
|
},
|
||
|
|
};
|