@mui/material#SelectProps TypeScript Examples
The following examples show how to use
@mui/material#SelectProps.
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: customFields.tsx From Cromwell with MIT License | 6 votes |
registerSelectCustomField = (settings: {
entityType: EDBEntity | string;
key: string;
label?: string;
options?: string[];
props?: SelectProps<string>;
}) => {
let customFieldValue;
registerCustomField({
id: getRandStr(10),
fieldType: 'Select',
...settings,
component: (props) => {
const [value, setValue] = useInitialValue(props.initialValue);
customFieldValue = value;
return (
<Select
style={{ margin: '15px 0' }}
label={settings.label}
value={value}
onChange={(event: SelectChangeEvent<string>) => {
setValue(event.target.value);
}}
size="small"
variant="standard"
fullWidth
options={settings.options?.map(opt => ({ label: opt, value: opt }))}
{...(settings.props ?? {})}
/>
)
},
saveData: () => (!customFieldValue) ? null : customFieldValue,
});
}
Example #2
Source File: Select.tsx From Cromwell with MIT License | 5 votes |
export function Select(props: { options?: ({ value: string | number | undefined; label: string; } | string | number | undefined)[]; selectStyle?: React.CSSProperties; selectClassName?: string; tooltipText?: string; tooltipLink?: string; } & SelectProps<string | number>) { const history = useHistory(); const openLink = () => { if (props.tooltipLink) { if (props.tooltipLink.startsWith('http')) { window.open(props.tooltipLink, '_blank'); } else { history.push(props.tooltipLink); } } } return ( <FormControl fullWidth={props.fullWidth} style={props.style} className={props.className} > <InputLabel style={props.variant === 'standard' ? { marginLeft: '-15px', marginTop: '8px', } : undefined} >{props.label}</InputLabel> <MuiSelect {...props} className={props.selectClassName} style={props.selectStyle} MenuProps={{ style: { zIndex: 10001 } }} endAdornment={( (props.tooltipText || props.tooltipLink) && ( <InputAdornment position="end" sx={{ mr: 1 }}> <Tooltip title={props.tooltipText}> <IconButton onClick={openLink}> <HelpOutlineOutlined /> </IconButton> </Tooltip> </InputAdornment> ) )} > {props.options?.map((option) => { const label = typeof option === 'object' ? option.label : option; const value = typeof option === 'object' ? option.value : option; return ( <MenuItem value={value} key={value + ''}>{label}</MenuItem> ) })} </MuiSelect> </FormControl> ) }