Files
decky-frontend-lib/src/deck-components/Dropdown.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-06-08 09:57:50 +02:00
import { ReactNode, VFC } from 'react';
import { CommonUIModule } from '../webpack';
import { ItemProps } from './Item';
2022-06-08 09:57:50 +02:00
export interface SingleDropdownOption {
data: any;
label: ReactNode;
2022-06-08 09:57:50 +02:00
options?: never;
}
export interface MultiDropdownOption {
label: ReactNode;
2022-06-08 09:57:50 +02:00
options: DropdownOption[];
data?: never;
}
export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
export interface DropdownProps {
rgOptions: DropdownOption[];
selectedOption: any;
2022-06-08 09:57:50 +02:00
disabled?: boolean;
onMenuWillOpen?(showMenu: () => void): void;
onMenuOpened?(): void;
onChange?(data: SingleDropdownOption): void;
contextMenuPositionOptions?: any;
menuLabel?: string;
strDefaultLabel?: string;
renderButtonValue?(element: ReactNode): ReactNode;
focusable?: boolean;
}
export const Dropdown = Object.values(CommonUIModule).find(
(mod: any) => mod?.prototype?.SetSelectedOption && mod?.prototype?.BuildMenu,
) as VFC<DropdownProps>;
export interface DropdownItemProps extends DropdownProps, ItemProps {}
2022-06-08 09:57:50 +02:00
export const DropdownItem = Object.values(CommonUIModule).find((mod: any) =>
mod?.toString()?.includes('"dropDownControlRef","description"'),
) as VFC<DropdownItemProps>;