top bar
This commit is contained in:
1 parent
a35e8e127f
commit
2ea96973ad
20 files changed
+372
-150
No files matched your search
@@ -0,0 +1,15 @@
|
||||
.MuiMenuItem-root.input-list--menu-item {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.input-list--menu-item .input-list--menu-item--description {
|
||||
font-size: 0.75em;
|
||||
max-width: 80vw;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.MuiSelect-select .input-list--menu-item--description {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import "./InputList.css";
|
||||
|
||||
import FormHelperText from "@mui/material/FormHelperText";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
@@ -15,11 +17,13 @@ export type Props<T extends string | Object> = {
|
||||
className?: string;
|
||||
prettyOptionLabels?: boolean;
|
||||
getKey?: (n: T) => string;
|
||||
getDescription?: (n: T) => string;
|
||||
placeholder?: any;
|
||||
title?: string;
|
||||
helperText?: string;
|
||||
endAdornment?: ReactNode;
|
||||
disabled?: boolean;
|
||||
fullWidth?: boolean;
|
||||
};
|
||||
export function InputList<T extends string | Object>({
|
||||
current,
|
||||
@@ -30,11 +34,13 @@ export function InputList<T extends string | Object>({
|
||||
className,
|
||||
prettyOptionLabels = true,
|
||||
getKey = String,
|
||||
getDescription,
|
||||
placeholder,
|
||||
title,
|
||||
helperText,
|
||||
endAdornment,
|
||||
disabled,
|
||||
fullWidth = true,
|
||||
}: Props<T>) {
|
||||
const invalidCurrent =
|
||||
current && !options.map(getKey).includes(getKey(current));
|
||||
@@ -43,7 +49,7 @@ export function InputList<T extends string | Object>({
|
||||
className={className}
|
||||
variant="filled"
|
||||
sx={{ marginRight: "0.25em", minWidth: `${label.length * 0.75}em` }}
|
||||
fullWidth
|
||||
fullWidth={fullWidth}
|
||||
disabled={disabled}
|
||||
>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
@@ -62,12 +68,20 @@ export function InputList<T extends string | Object>({
|
||||
label={label}
|
||||
variant="filled"
|
||||
error={invalidCurrent}
|
||||
fullWidth
|
||||
fullWidth={fullWidth}
|
||||
disabled={disabled}
|
||||
>
|
||||
{options.map((t, i) => (
|
||||
<MenuItem key={i} value={getKey(t)}>
|
||||
<MenuItem key={i} value={getKey(t)} className="input-list--menu-item">
|
||||
{prettyOptionLabels ? prettyName(getKey(t)) : getKey(t)}
|
||||
{!!getDescription && (
|
||||
<>
|
||||
<br />
|
||||
<div className="input-list--menu-item--description">
|
||||
{getDescription(t)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
Reference in new issue
Block a user