From a99fb4a22dcea3b6cd2a52f0dbd274d9a10f2e35 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Wed, 8 Jun 2022 09:57:50 +0200 Subject: [PATCH] feat(dropdown): add dropdown --- src/deck-components/Dropdown.tsx | 50 ++++++++++++++++++++++++++++++++ src/deck-components/index.ts | 1 + 2 files changed, 51 insertions(+) create mode 100644 src/deck-components/Dropdown.tsx diff --git a/src/deck-components/Dropdown.tsx b/src/deck-components/Dropdown.tsx new file mode 100644 index 0000000..e5e0e53 --- /dev/null +++ b/src/deck-components/Dropdown.tsx @@ -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; + +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; diff --git a/src/deck-components/index.ts b/src/deck-components/index.ts index c813b53..6d32427 100755 --- a/src/deck-components/index.ts +++ b/src/deck-components/index.ts @@ -1,5 +1,6 @@ export * from './Button'; export * from './ButtonItem'; +export * from './Dropdown'; export * from './Menu'; export * from './Modal'; export * from './Panel';