This commit is contained in:
2026-11-21 22:57:24 +08:00
commit 4bce6dd47e
209 changed files with 11072 additions and 0 deletions
@@ -0,0 +1,84 @@
import type { CSSProperties } from "react";
import type { CommonProps } from "../../utils/CommonProps";
import { usePopoverContext } from "./use-popover-context";
import {
FloatingArrow,
FloatingFocusManager,
FloatingPortal,
} from "@floating-ui/react";
import { useThemeContext } from "../theme/use-theme-context";
import { mergeClass } from "../../styles/utils/merge-class";
import { variantRecipe } from "../../styles/recipes/variant-recipe";
import { brandRecipe } from "../../styles/recipes/brand-recipe";
import { containerRecipe } from "../../styles/recipes/container-recipe";
export type PopoverDropdownProps = CommonProps;
export const PopoverDropdown = (props: PopoverDropdownProps) => {
const { children, className = "", style, ...rest } = props;
const {
refs,
floatingStyles,
getFloatingProps,
context,
arrowRef,
isMounted,
transitionStyles,
arrowWidth,
arrowHeight,
} = usePopoverContext()!;
const { themeClass, themeBaseClass } = useThemeContext()!;
const rootClass = mergeClass(
"text--md",
containerRecipe({
boxShadow: true,
rounded: 8,
padding: 12,
background: "base",
hasFocusOutline: "false",
}),
brandRecipe(),
themeBaseClass,
themeClass,
className,
);
const rootStyle: CSSProperties = {
...transitionStyles,
...floatingStyles,
...style,
};
const arrowStyle: CSSProperties = {
fill: "var(--base-background)",
};
return (
<>
{isMounted && (
<FloatingPortal>
<FloatingFocusManager context={context} modal={false}>
<div
className={rootClass}
ref={refs.setFloating}
style={rootStyle}
{...getFloatingProps({ ...rest })}
>
{children}
<FloatingArrow
ref={arrowRef}
context={context}
width={arrowWidth}
height={arrowHeight}
style={arrowStyle}
></FloatingArrow>
</div>
</FloatingFocusManager>
</FloatingPortal>
)}
</>
);
};