react-select#SingleValueProps TypeScript Examples
The following examples show how to use
react-select#SingleValueProps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactSelectCustomization.tsx From ke with MIT License | 6 votes |
function SingleValue<OptionType>({ ...props }: SingleValueProps<OptionType>): JSX.Element {
const { singleValue } = useStyles()
const { className, isDisabled } = props
const theme = useTheme()
return (
<ClassNames>
{({ cx: emotionCx, css }) => (
<selectComponents.SingleValue
{...props}
className={emotionCx(className, {
[css(chakraCss((singleValue as any)?._disabled)(theme))]: isDisabled,
})}
/>
)}
</ClassNames>
)
}
Example #2
Source File: popup-list.tsx From utopia with MIT License | 5 votes |
SingleValue = (props: SingleValueProps<SelectOption>) => {
return (
<components.SingleValue {...props}>
{props.data.icon == null ? null : <Icn {...props.data.icon} />}
<span style={{ paddingLeft: 4 }}>{props.children}</span>
</components.SingleValue>
)
}
Example #3
Source File: index.tsx From admin with MIT License | 5 votes |
SingleValue = ({ children, ...props }: SingleValueProps) => {
if (props.selectProps.menuIsOpen && props.selectProps.isSearchable) {
return null
}
return <components.SingleValue {...props}>{children}</components.SingleValue>
}
Example #4
Source File: SelectButton.tsx From rcsb-saguaro-app with MIT License | 5 votes |
private innerSelectButtonRender(defaultValue: SelectOptionInterface, index: number):JSX.Element {
const SingleValue:(props:SingleValueProps<OptionPropsInterface,false,GroupOptionPropsInterface>)=>JSX.Element = (props:SingleValueProps<OptionPropsInterface,false,GroupOptionPropsInterface>) => {
const label: string = typeof props.data.shortLabel === "string" ? props.data.shortLabel : props.data.label;
return (
<components.SingleValue {...props}>
{label}
</components.SingleValue>
)
};
let options: OptionsOrGroups<OptionPropsInterface,GroupOptionPropsInterface>;
if((this.props.options as Array<GroupedOptionsInterface>)[0].options == null){
options = (this.props.options as Array<SelectOptionInterface>).map((opt,index)=>{
const props: OptionPropsInterface = {...opt,value:index};
return props;
});
}else{
let i: number = 0;
options = (this.props.options as Array<GroupedOptionsInterface>).map((group,n)=>({
label: group.label,
options: group.options.map(opt=>({
...opt,
value:i++
}))
}))
}
const title: JSX.Element = typeof this.props.dropdownTitle === "string" ? <div style={{color:"grey",fontWeight:"bold",fontSize:12}}>{this.props.dropdownTitle}</div> : null;
return(
<div style={{display:"inline-block"}}>
{title}
<div >
<Select<OptionPropsInterface,false,GroupOptionPropsInterface>
options={options}
isSearchable={false}
onChange={this.change.bind(this)}
styles={this.configStyle()}
components={{ SingleValue, Option: this.props.optionProps ? (props)=>{
return this.props.optionProps({...props,children:<components.Option {...props} children={props.children}/>});
} : ((props)=>(<components.Option {...props} children={props.children}/>)) }}
defaultValue={{...defaultValue,value:index}}
/>
</div>
</div>
);
}