2024-02-23 06:23:32 -05:00
|
|
|
import React from 'react'
|
|
|
|
import {
|
2024-04-16 11:06:42 -04:00
|
|
|
Dropdown as BS5Dropdown,
|
|
|
|
DropdownToggle as BS5DropdownToggle,
|
|
|
|
DropdownMenu as BS5DropdownMenu,
|
|
|
|
DropdownItem as BS5DropdownItem,
|
|
|
|
DropdownDivider as BS5DropdownDivider,
|
2024-02-23 06:23:32 -05:00
|
|
|
} from 'react-bootstrap-5'
|
|
|
|
import type {
|
|
|
|
DropdownProps,
|
|
|
|
DropdownItemProps,
|
|
|
|
DropdownToggleProps,
|
|
|
|
DropdownMenuProps,
|
|
|
|
} from '@/features/ui/components/types/dropdown-menu-props'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
|
|
|
|
export function Dropdown({ ...props }: DropdownProps) {
|
2024-04-16 11:06:42 -04:00
|
|
|
return <BS5Dropdown {...props} />
|
2024-02-23 06:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function DropdownItem({
|
|
|
|
active,
|
|
|
|
children,
|
|
|
|
description,
|
|
|
|
leadingIcon,
|
|
|
|
trailingIcon,
|
|
|
|
...props
|
|
|
|
}: DropdownItemProps) {
|
|
|
|
const trailingIconType = active ? 'check' : trailingIcon
|
|
|
|
return (
|
|
|
|
<li>
|
2024-04-16 11:06:42 -04:00
|
|
|
<BS5DropdownItem
|
2024-02-23 06:23:32 -05:00
|
|
|
active={active}
|
|
|
|
className={description ? 'dropdown-item-description-container' : ''}
|
|
|
|
role="menuitem"
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{leadingIcon && (
|
|
|
|
<MaterialIcon
|
|
|
|
className="dropdown-item-leading-icon"
|
|
|
|
type={leadingIcon}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{children}
|
|
|
|
{trailingIconType && (
|
|
|
|
<MaterialIcon
|
|
|
|
className="dropdown-item-trailing-icon"
|
|
|
|
type={trailingIconType}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{description && (
|
|
|
|
<span className="dropdown-item-description">{description}</span>
|
|
|
|
)}
|
2024-04-16 11:06:42 -04:00
|
|
|
</BS5DropdownItem>
|
2024-02-23 06:23:32 -05:00
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function DropdownToggle({ ...props }: DropdownToggleProps) {
|
2024-04-16 11:06:42 -04:00
|
|
|
return <BS5DropdownToggle {...props} />
|
2024-02-23 06:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function DropdownMenu({ as = 'ul', ...props }: DropdownMenuProps) {
|
2024-04-16 11:06:42 -04:00
|
|
|
return <BS5DropdownMenu as={as} role="menubar" {...props} />
|
2024-02-23 06:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function DropdownDivider() {
|
2024-04-16 11:06:42 -04:00
|
|
|
return <BS5DropdownDivider aria-hidden="true" />
|
2024-02-23 06:23:32 -05:00
|
|
|
}
|