mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-20 01:50:08 +02:00
feat(dropdown): add dropdown
This commit is contained in:
50
src/deck-components/Dropdown.tsx
Normal file
50
src/deck-components/Dropdown.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { ReactNode, VFC } from 'react';
|
||||
|
||||
import { CommonUIModule } from '../webpack';
|
||||
|
||||
export interface SingleDropdownOption {
|
||||
data: number;
|
||||
label: string;
|
||||
|
||||
options?: never;
|
||||
}
|
||||
|
||||
export interface MultiDropdownOption {
|
||||
label: string;
|
||||
options: DropdownOption[];
|
||||
|
||||
data?: never;
|
||||
}
|
||||
|
||||
export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
|
||||
|
||||
export interface DropdownProps {
|
||||
rgOptions: DropdownOption[];
|
||||
selectedOption: number | null;
|
||||
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 {
|
||||
label?: string;
|
||||
tooltip?: string;
|
||||
description?: string;
|
||||
layout?: 'below';
|
||||
bottomSeparator?: boolean;
|
||||
indentLevel?: number;
|
||||
}
|
||||
|
||||
export const DropdownItem = Object.values(CommonUIModule).find((mod: any) =>
|
||||
mod?.toString()?.includes('"dropDownControlRef","description"'),
|
||||
) as VFC<DropdownItemProps>;
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './Button';
|
||||
export * from './ButtonItem';
|
||||
export * from './Dropdown';
|
||||
export * from './Menu';
|
||||
export * from './Modal';
|
||||
export * from './Panel';
|
||||
|
||||
Reference in New Issue
Block a user