import { preventDefault, useContainer } from '@bigbluebutton/editor'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
import { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'
import { Button, TLUiButtonProps } from './Button'
import { Icon } from './Icon'
/** @public */
export function Root({
id,
children,
modal = false,
debugOpen = false,
}: {
id: string
children: any
modal?: boolean
debugOpen?: boolean
}) {
const [open, onOpenChange] = useMenuIsOpen(id)
return (
{children}
)
}
/** @public */
export function Trigger({
children,
'data-testid': testId,
}: {
children: any
'data-testid'?: string
}) {
return (
preventDefault(e)}
>
{children}
)
}
/** @public */
export function Content({
side = 'bottom',
align = 'start',
sideOffset = 8,
alignOffset = 8,
children,
}: {
children: any
alignOffset?: number
sideOffset?: number
align?: 'start' | 'center' | 'end'
side?: 'bottom' | 'top' | 'right' | 'left'
}) {
const container = useContainer()
return (
{children}
)
}
/** @public */
export function Sub({ id, children }: { id: string; children: any }) {
const [open, onOpenChange] = useMenuIsOpen(id)
return (
{children}
)
}
/** @public */
export function SubTrigger({
label,
'data-testid': testId,
'data-direction': dataDirection,
}: {
label: TLUiTranslationKey | Exclude
'data-testid'?: string
'data-direction'?: 'left' | 'right'
}) {
return (
)
}
/** @public */
export function SubContent({
alignOffset = 0,
sideOffset = 5,
children,
}: {
alignOffset?: number
sideOffset?: number
children: any
}) {
const container = useContainer()
return (
{children}
)
}
/** @public */
export function Group({
children,
size = 'medium',
}: {
children: any
size?: 'tiny' | 'small' | 'medium' | 'wide'
}) {
return (
{children}
)
}
/** @public */
export function Indicator() {
return (
)
}
/** @public */
export interface DropdownMenuItemProps extends TLUiButtonProps {
noClose?: boolean
}
/** @public */
export function Item({ noClose, ...props }: DropdownMenuItemProps) {
return (
)
}
/** @public */
export interface DropdownMenuCheckboxItemProps {
checked?: boolean
onSelect?: (e: Event) => void
disabled?: boolean
title: string
children: any
}
/** @public */
export function CheckboxItem({ children, onSelect, ...rest }: DropdownMenuCheckboxItemProps) {
return (
{
onSelect?.(e)
preventDefault(e)
}}
{...rest}
>
{children}
)
}
/** @public */
export function RadioItem({ children, onSelect, ...rest }: DropdownMenuCheckboxItemProps) {
return (
{
onSelect?.(e)
preventDefault(e)
}}
{...rest}
>
{children}
)
}