import { Column, SelectField } from '@8base/boost'; import cx from 'classnames'; import React, { useCallback } from 'react'; import { IOption } from 'types'; import List from '../list'; // -- TYPES export interface ISelectBrowserProps { input: { value: any; onChange?: (value: any) => any; }; className: { list?: string; }; options: IOption[]; availableOptions: OptionBodyProps[]; onItemSelect: (option: IOption) => any; onInputChange?: (value: string, meta: { action: string }) => any; label?: string; optionBody?: React.ComponentType; inputValue?: string; placeholder?: string; loading?: boolean; multiple?: boolean; } export interface ISelectBrowserListItemProps extends IOption { onItemSelect: ISelectBrowserProps['onItemSelect']; children: React.ReactNode; } // -- COMPONENTS function SelectBrowserListItem({ label, value, onItemSelect, children, }: ISelectBrowserListItemProps) { const onClick = useCallback(() => { onItemSelect({ label, value }); }, []); return {children}; } // -- MAIN function SelectBrowser({ availableOptions, onItemSelect, loading, className, optionBody: OptionBody, ...selectProps }: ISelectBrowserProps) { const cnList = cx(className.list); return ( {loading ? (
Loading...
) : ( {availableOptions.map(option => ( {OptionBody ? : option.label} ))} )}
); } SelectBrowser.defaultProps = { className: {}, }; export default SelectBrowser;