Created
August 11, 2017 14:44
-
-
Save thomas-mcdonald/e703bcc940e16ee6ba8fff8bc554fdb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ISelectProps } from "@blueprintjs/labs"; | |
import * as React from "react"; | |
import { DropdownButton } from "./DropdownButton"; | |
interface IDisableableSelectProps { | |
disabled?: boolean; | |
text: string; | |
} | |
export function disableableSelect<T>( | |
InitialSelectComponent: React.ComponentClass<ISelectProps<T>> | |
): React.ComponentClass<ISelectProps<T> & IDisableableSelectProps> { | |
return class DisableableSelectWrapper extends React.Component<ISelectProps<T> & IDisableableSelectProps> { | |
public render() { | |
const { disabled = false, items, itemRenderer, onItemSelect, text } = this.props; | |
if (disabled) { | |
return <DropdownButton disabled={true} text={text} />; | |
} | |
return ( | |
<InitialSelectComponent items={items} itemRenderer={itemRenderer} onItemSelect={onItemSelect}> | |
<DropdownButton text={text} /> | |
</InitialSelectComponent> | |
); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment