mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-19 17:40:08 +02:00
fix(dropdown): hack to fix styling in dropdownitem
This commit is contained in:
49
src/components/Dropdown.tsx
Normal file
49
src/components/Dropdown.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { ReactNode, FC } from 'react';
|
||||
|
||||
import { CommonUIModule } from '../webpack';
|
||||
import { ItemProps } from './Item';
|
||||
import { createPropListRegex } from '../utils';
|
||||
import type { ContextMenuPositionOptions } from './Menu';
|
||||
|
||||
export interface SingleDropdownOption {
|
||||
data: any;
|
||||
label: ReactNode;
|
||||
|
||||
options?: never;
|
||||
}
|
||||
|
||||
export interface MultiDropdownOption {
|
||||
label: ReactNode;
|
||||
options: DropdownOption[];
|
||||
|
||||
data?: never;
|
||||
}
|
||||
|
||||
export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
|
||||
|
||||
export interface DropdownProps {
|
||||
rgOptions: DropdownOption[];
|
||||
selectedOption: any;
|
||||
disabled?: boolean;
|
||||
onMenuWillOpen?(showMenu: () => void): void;
|
||||
onMenuOpened?(): void;
|
||||
onChange?(data: SingleDropdownOption): void;
|
||||
contextMenuPositionOptions?: ContextMenuPositionOptions;
|
||||
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 FC<DropdownProps>;
|
||||
|
||||
export interface DropdownItemProps extends DropdownProps, ItemProps {}
|
||||
|
||||
const dropdownItemRegex = createPropListRegex(["dropDownControlRef", "description"], false);
|
||||
export const DropdownItemInternal = Object.values(CommonUIModule).find((mod: any) =>
|
||||
mod?.toString && dropdownItemRegex.test(mod.toString()),
|
||||
) as FC<DropdownItemProps>;
|
||||
|
||||
export const DropdownItem = ((args: DropdownItemProps) => <DropdownItemInternal childrenContainerWidth="min" {...args}/>) as FC<DropdownItemProps>;
|
||||
Reference in New Issue
Block a user