-
}
+ alwaysShow={true}
+ useTransition={false}
+ classPanel="absolute right-0 z-10 origin-top-right whitespace-nowrap rounded-lg border border-gray-10 bg-surface p-1 shadow-subtle dark:bg-gray-5"
+ panelStyle={{
top: '44px',
minWidth: '160px',
}}
- static
- >
- {disableRoleChange ? (
- <>>
- ) : (
+ panel={(close) => (
<>
- {/* Editor */}
-
+ {!disableRoleChange && (
+ <>
+ {/* Editor */}
+
- {/* Reader */}
+ {/* Reader */}
+
+
+
+ >
+ )}
+ {/* Remove */}
-
-
>
)}
- {/* Remove */}
-
-
-
- ) : (
- <>>
+ />
+
);
};
diff --git a/src/components/Popover.tsx b/src/components/Popover.tsx
index 77589b6ff3..692032c4a4 100644
--- a/src/components/Popover.tsx
+++ b/src/components/Popover.tsx
@@ -1,35 +1,78 @@
import { Popover as HPopover, Transition } from '@headlessui/react';
import { ReactNode } from 'react';
+export interface PopoverRenderProps {
+ open: boolean;
+ close: () => void;
+ Button: typeof HPopover.Button;
+ Panel: typeof HPopover.Panel;
+}
+
interface PopoverProps {
- childrenButton: ReactNode;
- panel: ReactNode;
+ childrenButton?: ReactNode;
+ panel?: ReactNode | ((close: () => void) => ReactNode);
className?: string;
classButton?: string;
+ classPanel?: string;
+ panelStyle?: React.CSSProperties;
+ buttonAs?: React.ElementType;
+ useTransition?: boolean;
+ alwaysShow?: boolean;
+ children?: (props: PopoverRenderProps) => ReactNode;
}
+
+const DEFAULT_PANEL_CLASS =
+ 'absolute right-0 z-50 mt-1 rounded-md border border-gray-10 bg-surface py-1.5 shadow-subtle dark:bg-gray-5';
+
export default function Popover({
childrenButton,
panel,
- className,
- classButton,
+ className = '',
+ classButton = '',
+ classPanel,
+ panelStyle,
+ buttonAs,
+ useTransition = true,
+ alwaysShow = false,
+ children,
}: Readonly