Skip to content

Commit

Permalink
feat(dropdown): add dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyCrazy committed Jun 8, 2022
1 parent d8794ef commit a99fb4a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/deck-components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions src/deck-components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './Button';
export * from './ButtonItem';
export * from './Dropdown';
export * from './Menu';
export * from './Modal';
export * from './Panel';
Expand Down

0 comments on commit a99fb4a

Please sign in to comment.