/* * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { type ComponentProps, type CSSProperties, useCallback } from "react"; import { useArgs } from "storybook/preview-api"; import { expect, screen, waitFor } from "storybook/test"; import { Classes } from "../../common"; import { Button } from "../button/buttons"; import { InputGroup } from "../forms/inputGroup"; import { Code, H3, H4 } from "../html/html"; import { Overlay2 } from "./overlay2"; const disabledArgs = ["childRef", "childRefs", "portalStopPropagationEvents"] as const satisfies ReadonlyArray< keyof ComponentProps >; const meta = { title: "Core/Overlays/Overlay2", component: Overlay2, parameters: { layout: "centered", }, tags: ["autodocs"], args: { isOpen: false, hasBackdrop: true, canEscapeKeyClose: true, canOutsideClickClose: true, autoFocus: true, enforceFocus: true, usePortal: true, transitionDuration: 0, transitionName: "no-transition", }, argTypes: { hasBackdrop: { control: "boolean" }, canEscapeKeyClose: { control: "boolean" }, canOutsideClickClose: { control: "boolean" }, autoFocus: { control: "boolean" }, enforceFocus: { control: "boolean" }, usePortal: { control: "boolean" }, lazy: { control: "boolean" }, shouldReturnFocusOnClose: { control: "boolean" }, transitionDuration: { control: "number" }, ...disabledArgs.reduce( (acc, argName) => { acc[argName] = { table: { disable: true } }; return acc; }, {} as Record<(typeof disabledArgs)[number], { table: { disable: boolean } }>, ), }, } satisfies Meta; export default meta; type Story = StoryObj; const OVERLAY_CONTENT_STYLE: CSSProperties = { background: "var(--bp-surface-background-color, white)", borderRadius: 6, boxShadow: "0 2px 10px rgba(0,0,0,0.2)", left: "calc(50% - 200px)", margin: "10vh 0", padding: 30, position: "fixed", top: 0, width: 400, zIndex: 20, }; /** * A basic overlay with backdrop. Click the button to open the overlay, then click * the backdrop or press Escape to close it. */ export const Default: Story = { render: function RenderDefault(args) { const [, updateArgs] = useArgs(); const handleOpen = useCallback(() => updateArgs({ isOpen: true }), [updateArgs]); const handleClose = useCallback(() => updateArgs({ isOpen: false }), [updateArgs]); return ( <>