39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
/**
|
|
* Popover Xpeditis, sur @radix-ui/react-popover.
|
|
* Portalise : plus de clipping par un parent en `overflow: hidden`.
|
|
*/
|
|
const Popover = PopoverPrimitive.Root;
|
|
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
|
|
const PopoverContent = React.forwardRef<
|
|
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
>(({ className, align = 'center', sideOffset = 6, ...props }, ref) => (
|
|
<PopoverPrimitive.Portal>
|
|
<PopoverPrimitive.Content
|
|
ref={ref}
|
|
align={align}
|
|
sideOffset={sideOffset}
|
|
className={cn(
|
|
'z-50 rounded-lg border border-border bg-white p-4 text-brand-navy shadow-sm',
|
|
'w-72 max-w-[calc(100vw-2rem)]',
|
|
'origin-[--radix-popover-content-transform-origin]',
|
|
'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
|
|
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</PopoverPrimitive.Portal>
|
|
));
|
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
|
|
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|