trigger state autofill
This commit is contained in:
1 parent
736a6053ef
commit
326775848b
8 files changed
+440
-268
No files matched your search
@@ -5,6 +5,7 @@ import Chip from "@mui/material/Chip";
|
||||
import { Badge } from "@mui/material";
|
||||
import { SearchItem } from "./extras";
|
||||
import { ReactNode } from "react";
|
||||
import { prettyName } from "utils/formatting";
|
||||
|
||||
export type BaseOption<T = {}> = {
|
||||
id: string;
|
||||
@@ -204,7 +205,11 @@ export function InputAutoComplete<T extends Option>(
|
||||
size="medium"
|
||||
label={
|
||||
<>
|
||||
{id === label ? <span>{label}</span> : <b>{label}</b>}
|
||||
{id === label ? (
|
||||
<span>{prettyName(label)}</span>
|
||||
) : (
|
||||
<b>{label}</b>
|
||||
)}
|
||||
{id !== label && !props.onlyShowLabel && (
|
||||
<small>{id}</small>
|
||||
)}
|
||||
|
||||
@@ -41,6 +41,7 @@ export function InputList<T extends string | Object>({
|
||||
className={className}
|
||||
variant="filled"
|
||||
sx={{ marginRight: "0.25em", minWidth: `${label.length * 0.75}em` }}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
<Select
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { PropsWithChildren, ReactNode, useState } from "react";
|
||||
import React, { ReactNode, useState } from "react";
|
||||
import { useToolTip } from "tooltip/context";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
@@ -31,59 +30,56 @@ export default function InputText({
|
||||
additionalTooltipFilters = {},
|
||||
multiline = false,
|
||||
maxRows = 4,
|
||||
children,
|
||||
className,
|
||||
placeholder,
|
||||
required,
|
||||
}: PropsWithChildren<Props>) {
|
||||
}: Props) {
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
return (
|
||||
<InputWrapper className={className} label="">
|
||||
<TextField
|
||||
multiline={multiline}
|
||||
maxRows={maxRows}
|
||||
fullWidth
|
||||
inputMode="text"
|
||||
variant="filled"
|
||||
focused={isFocused}
|
||||
label={label}
|
||||
value={value}
|
||||
title={title}
|
||||
helperText={helperText}
|
||||
placeholder={placeholder}
|
||||
InputProps={{
|
||||
endAdornment,
|
||||
}}
|
||||
required={required}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
onBlur={() => {
|
||||
setIsFocused(false);
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
setIsFocused(true);
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{children}
|
||||
</InputWrapper>
|
||||
<TextField
|
||||
className={className}
|
||||
multiline={multiline}
|
||||
maxRows={maxRows}
|
||||
fullWidth
|
||||
inputMode="text"
|
||||
variant="filled"
|
||||
focused={isFocused}
|
||||
label={label}
|
||||
value={value}
|
||||
title={title}
|
||||
helperText={helperText}
|
||||
placeholder={placeholder}
|
||||
InputProps={{
|
||||
endAdornment,
|
||||
}}
|
||||
required={required}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
onBlur={() => {
|
||||
setIsFocused(false);
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
setIsFocused(true);
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import "./extras.css";
|
||||
import { FC } from "react";
|
||||
import parse from "autosuggest-highlight/parse";
|
||||
import match from "autosuggest-highlight/match";
|
||||
import { prettyName } from "utils/formatting";
|
||||
|
||||
export const HighlightElm: FC<{
|
||||
text: string;
|
||||
@@ -38,7 +39,7 @@ export const SearchItem: FC<{
|
||||
let inner = (
|
||||
<>
|
||||
<b>
|
||||
<HighlightElm text={label} searchTerm={searchTerm} />
|
||||
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
|
||||
</b>{" "}
|
||||
<small>
|
||||
<HighlightElm text={id} searchTerm={searchTerm} />
|
||||
@@ -51,7 +52,7 @@ export const SearchItem: FC<{
|
||||
inner = (
|
||||
<>
|
||||
<b>
|
||||
<HighlightElm text={label} searchTerm={searchTerm} />
|
||||
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
|
||||
</b>{" "}
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user