import Button from '@/components/Button'; import Modal, { ModalProps } from '@/components/Modal'; import { useArgs } from '@storybook/preview-api'; import { Meta, StoryObj } from '@storybook/react'; const meta: Meta = { title: 'Modal', component: Modal, tags: ['autodocs'], decorators: [(Story) =>
{}
], argTypes: { onInteractOutside: { control: false, // no auto control, but we’ll log manually description: ` onInteractOutside={(e) => e.preventDefault()}`, table: { category: 'Events', }, }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { isOpen: true, showXButton: true, onClose: () => {}, }, render: () => { const [args, updateArgs] = useArgs(); return ( <> { console.log('Outside interaction triggered:', event); // Example: prevent closing when clicked outside event.preventDefault(); alert('You clicked outside the modal!\nRemove e.preventDefault() to allow closing.'); // If consumer passes custom handler, call it args.onInteractOutside?.(event); }} onClose={() => updateArgs({ ...args, isOpen: false })} > Modal Title Lorem ipsum dolor sit amet consectetur adipisicing elit. This modal won’t close if you click outside because we called e.preventDefault() in onInteractOutside. if you want to close the modal on outside click, you can set so don't call e.preventDefault() in onInteractOutside. ); }, };