/* * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { StoryLabel } from "@storybook-common"; import { useCallback, useState } from "react"; import { useArgs } from "storybook/preview-api"; import { expect, screen, waitFor } from "storybook/test"; import { Box, Flex } from "@blueprintjs/labs"; import { Classes } from "../../common"; import { Button } from "../button/buttons"; import { Dialog } from "../dialog/dialog"; import { DialogBody } from "../dialog/dialogBody"; import { DialogFooter } from "../dialog/dialogFooter"; import { ControlGroup } from "../forms/controlGroup"; import { Checkbox } from "../forms/controls"; import { InputGroup } from "../forms/inputGroup"; import { Code } from "../html/html"; import { HTMLSelect } from "../html-select/htmlSelect"; import { Menu } from "../menu/menu"; import { MenuItem } from "../menu/menuItem"; import { PopoverAnimation, PopoverInteractionKind } from "../popover/popoverProps"; import { Slider } from "../slider/slider"; import { PopoverNext } from "./popoverNext"; import { POPOVER_NEXT_PLACEMENTS, type PopoverNextPlacement, type PopoverRenderTargetProps } from "./popoverNextProps"; const disabledArgs = [ "autoUpdateOptions", "backdropProps", "middleware", "portalClassName", "portalContainer", "renderTarget", "rootBoundary", "targetProps", "targetTagName", "popupKind", ] as const satisfies ReadonlyArray>; const meta = { title: "Core/Overlays/PopoverNext", component: PopoverNext, parameters: { layout: "centered", }, tags: ["autodocs"], args: { disabled: false, arrow: true, matchTargetWidth: false, interactionKind: PopoverInteractionKind.CLICK, hasBackdrop: false, }, argTypes: { placement: { control: "select", options: POPOVER_NEXT_PLACEMENTS, }, interactionKind: { control: "select", options: Object.values(PopoverInteractionKind), }, disabled: { control: "boolean" }, arrow: { control: "boolean" }, matchTargetWidth: { control: "boolean" }, hasBackdrop: { control: "boolean" }, fill: { control: "boolean" }, canEscapeKeyClose: { control: "boolean" }, usePortal: { control: "boolean" }, isOpen: { control: "boolean" }, defaultIsOpen: { control: "boolean" }, animation: { control: "select", options: Object.values(PopoverAnimation), }, hoverOpenDelay: { control: "number" }, hoverCloseDelay: { control: "number" }, onClose: { action: "closed" }, ...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 SAMPLE_MENU = ( ); /** * A basic PopoverNext that opens a menu when clicked. PopoverNext wraps its children * and uses them as the trigger target. By default, clicking outside or on a menu item * closes the popover. */ export const Default: Story = { render: args => (