Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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