import type { Meta, StoryObj } from '@storybook/vue3-vite' import { ref } from 'vue' import CpDialog from '@/components/CpDialog.vue' const meta = { title: 'Organisms/CpDialog', component: CpDialog, argTypes: { maxWidth: { control: 'number', description: 'The maximum width of the dialog', }, onClose: { action: 'closed' }, }, } satisfies Meta export default meta type Story = StoryObj /** * Default dialog featuring every common part: title and subtitle slots, * body content and a footer slot. Use the controls to experiment with each * prop in isolation. */ export const Default: Story = { args: { maxWidth: 600, title: 'Dialog title', subtitle: 'Dialog subtitle', }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog

This is the default slot content. You can put any content here.

`, }), } /** * Pass the title and subtitle as plain strings through props instead of * slots — the simplest way to compose a dialog. */ export const TitleSubtitleWithProps: Story = { args: { maxWidth: 600, title: 'Dialog title', subtitle: 'Dialog subtitle', }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog with string title/subtitle

This is the default slot content. You can put any content here.

`, }), } /** * Dialog with only body content — no title, subtitle or header. */ export const ContentOnly: Story = { args: { maxWidth: 600, }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog (content only)

This is the default slot content with no title or subtitle.

`, }), } /** * Provide rich title and subtitle through slots. Use `titleTag`/ * `subtitleTag` to change the underlying element (e.g. `div` to allow * flex content). */ export const TitleSubtitleWithSlots: Story = { args: { maxWidth: 560, }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog (flex title/subtitle)

Body content. Title and subtitle above are divs with flex layout.

`, }), } /** * Enable `isClosableOnClickOutside` so the dialog dismisses when the user * clicks the backdrop. */ export const ClosableOnClickOutside: Story = { args: { maxWidth: 600, isClosableOnClickOutside: true, }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog

This is the default slot content. You can put any content here.

`, }), } /** * Prevent the dialog from being closed by the user. */ export const PreventClose: Story = { args: { maxWidth: 600, preventClose: true, }, render: (args) => ({ setup() { const isOpen = ref(false) return { args, isOpen } }, template: ` Open Dialog

This is the default slot content. You can put any content here.

`, }), }