{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog-story",
  "title": "Dialog Story",
  "author": "Lloyd Richards <lloyd.d.richards@gmail.com>",
  "description": "Interactive Storybook stories demonstrating dialog component usage and variants",
  "registryDependencies": [
    "dialog"
  ],
  "files": [
    {
      "path": "registry/ui/dialog-story/dialog-base.stories.tsx",
      "content": "import { expect, userEvent, waitFor, within } from \"storybook/test\";\n// Replace nextjs-vite with the name of your framework\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\n\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n} from \"@/components/ui/dialog\";\n\n/**\n * A window overlaid on either the primary window or another dialog window,\n * rendering the content underneath inert.\n */\nconst meta = {\n  title: \"ui/base/Dialog\",\n  component: Dialog,\n  tags: [\"autodocs\"],\n  argTypes: {},\n  render: (args) => (\n    <Dialog {...args}>\n      <DialogTrigger>Open</DialogTrigger>\n      <DialogContent>\n        <DialogHeader>\n          <DialogTitle>Are you absolutely sure?</DialogTitle>\n          <DialogDescription>\n            This action cannot be undone. This will permanently delete your\n            account and remove your data from our servers.\n          </DialogDescription>\n        </DialogHeader>\n        <DialogFooter className=\"gap-4\">\n          <DialogClose className=\"hover:underline\">Cancel</DialogClose>\n          <DialogClose className=\"bg-primary text-primary-foreground rounded px-4 py-2\">\n            Continue\n          </DialogClose>\n        </DialogFooter>\n      </DialogContent>\n    </Dialog>\n  ),\n  parameters: {\n    layout: \"centered\",\n  },\n} satisfies Meta<typeof Dialog>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\n/**\n * The default form of the dialog.\n */\nexport const Default: Story = {};\n\nexport const ShouldOpenCloseWithContinue: Story = {\n  name: \"when clicking Continue button, should close the dialog\",\n  tags: [\"!dev\", \"!autodocs\"],\n  play: async ({ canvasElement, step }) => {\n    const canvasBody = within(canvasElement.ownerDocument.body);\n\n    await step(\"Open the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /open/i }),\n      );\n      const dialog = await canvasBody.findByRole(\"dialog\");\n      await waitFor(() => {\n        expect(dialog).toHaveAttribute(\"data-open\");\n      });\n    });\n\n    await step(\"Close the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /continue/i }),\n      );\n      await waitFor(() => {\n        expect(canvasBody.queryByRole(\"dialog\")).not.toBeInTheDocument();\n      });\n    });\n  },\n};\n\nexport const ShouldOpenCloseWithCancel: Story = {\n  name: \"when clicking Cancel button, should close the dialog\",\n  tags: [\"!dev\", \"!autodocs\"],\n  play: async ({ canvasElement, step }) => {\n    const canvasBody = within(canvasElement.ownerDocument.body);\n\n    await step(\"Open the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /open/i }),\n      );\n      const dialog = await canvasBody.findByRole(\"dialog\");\n      await waitFor(() => {\n        expect(dialog).toHaveAttribute(\"data-open\");\n      });\n    });\n\n    await step(\"Close the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /cancel/i }),\n      );\n      await waitFor(() => {\n        expect(canvasBody.queryByRole(\"dialog\")).not.toBeInTheDocument();\n      });\n    });\n  },\n};\n\nexport const ShouldOpenCloseCross: Story = {\n  name: \"when clicking Close icon, should close the dialog\",\n  tags: [\"!dev\", \"!autodocs\"],\n  play: async ({ canvasElement, step }) => {\n    const canvasBody = within(canvasElement.ownerDocument.body);\n\n    await step(\"Open the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /open/i }),\n      );\n      const dialog = await canvasBody.findByRole(\"dialog\");\n      await waitFor(() => {\n        expect(dialog).toHaveAttribute(\"data-open\");\n      });\n    });\n\n    await step(\"Close the dialog\", async () => {\n      await userEvent.click(\n        await canvasBody.findByRole(\"button\", { name: /close/i }),\n      );\n      await waitFor(() => {\n        expect(canvasBody.queryByRole(\"dialog\")).not.toBeInTheDocument();\n      });\n    });\n  },\n};\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "ui",
    "storybook",
    "dialog",
    "modal"
  ],
  "type": "registry:component"
}