// import * as React from 'react'; // import { // Component, // ComponentClass, // cloneElement, // MouseEvent, // ReactChildren, // ReactElement, // } from 'react'; // import getPassThrough, { PassTroughFunction } from '../../utils/getPassThrough'; // import filterReactChildren from '../../utils/filterReactChildren'; // import isComponentOfType from '../../utils/isComponentOfType'; // import { DropdownOptionProps } from './DropdownOption'; // import { DropdownOptionsProps } from './DropdownOptions'; // export interface DropdownProps { // active: boolean; // children: ReactChildren; // className?: string; // disabled: boolean; // error: Array | string | boolean; // fit: boolean; // isOptionSelected?(current: T, item: T): boolean; // label: string; // name: string; // onChange(value: T): void; // onClick(event: MouseEvent): void; // onClickOutside?(): void; // onFocus(): void; // placeholder?: string; // showError?: boolean; // value: T; // } // export interface ValueNodeProps { // onClick(event: MouseEvent): void; // } // export interface LabelNodeProps { // hasValue: boolean; // } // export interface DropdownFactoryArgs { // DropdownOption: ComponentClass>; // DropdownOptions: ComponentClass>; // DefaultTemplate: ComponentClass<{}>; // PlaceholderNode: ComponentClass<{}>; // LabelNode: ComponentClass; // WrapperNode: ComponentClass<{}>; // ValueNode: ComponentClass; // passthrough: PassTroughFunction< // DropdownProps, // 'WrapperNode' | 'DropdownOptions' // >; // } // export default function dropdownFactory({ // DefaultTemplate, // DropdownOption, // DropdownOptions, // LabelNode, // PlaceholderNode, // ValueNode, // WrapperNode, // passthrough, // }: DropdownFactoryArgs): ComponentClass> { // const passProps = getPassThrough(passthrough); // function getSelectedDropdownOption(props: DropdownProps) { // return filterReactChildren(props.children, child => { // if (isComponentOfType(DropdownOption, child)) { // const option = child as ReactElement>; // return ( // !option.props.disabled && // props.value && // props.value === option.props.value // ); // } // return false; // })[0]; // } // function getDropdownOptionValue( // option: ReactElement> | undefined, // ) { // return option ? option.props.children : undefined; // } // return class Dropdown extends Component, {}> { // handleClick = (event: MouseEvent) => { // this.props.onClick(event); // }; // handleClickOption = (event: MouseEvent, value: T) => { // this.props.onChange(value); // }; // isOptionSelected = (current: T, item: T) => // this.props.isOptionSelected // ? this.props.isOptionSelected(current, item) // : current === item; // getSelectedDropdownOption = () => ( // filterReactChildren(this.props.children, child => { // if (isComponentOfType(DropdownOption, child)) { // const option = child as ReactElement>; // return ( // !option.props.disabled && // this.props.value && // this.isOptionSelected(this.props.value, option.props.value) // ); // } // return false; // })[0] // ); // render() { // const { // active, // children, // isOptionSelected, // label, // onClickOutside, // placeholder, // value, // } = this.props; // const selectedValue = getDropdownOptionValue( // getSelectedDropdownOption(this.props), // ); // const renderSelected = // typeof selectedValue === 'string' ? ( // {selectedValue} // ) : ( // selectedValue // ); // const hasValue = !!selectedValue; // const renderValue = selectedValue // ? renderSelected // : {placeholder}; // return ( // // // {label} // // // {cloneElement(renderValue, { selected: false })} // // {children} // // // // ); // } // }; // }